Quick start tutorial: Logging and viewing transactions
Estimated time to complete: 5-7 minutes
Martini allows you to log service invocations that have occurred within the server using Tracker1. This data can then be used for generating reports, auditing, and troubleshooting.
Tracker is a fully-indexed logging engine that allows you to quickly and easily search for data that's been sent to and received by Martini. In this tutorial, you'll be taught how to log service invocations programmatically using a function, and how to view the resulting document in the Tracker user interface.
Create the data-logging service
Services can be invoked from various places. This includes endpoints, over HTTP, and other services. For each of these types of invocations, Martini provides logging capabilities to Tracker.
To keep the tutorial short, this page will only discuss how you can log an invocation from a service. This is done by
calling any of the Tracker
.addDocument(...)
functions.
Consider the following service:
It has seven string input properties:
internalId
, externalId
, documentTypeId
, senderId
, receiverId
, content
, and stateName
.
It calls the addDocument(...)
function, and then provides the function's arguments
by mapping them from input properties of the same name and type.
Copy and paste properties
The service inputs and function parameters have the same name and type. To declare your input properties faster in Martini Desktop, just copy the function parameters from the Mapper view and then paste it on the left side of the Input/Output view.
Copy and paste mappings
Instead of creating a map line per parameter, copy the following JSON and paste it on the Mapper view to create map lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
How do you know the data type of a property?
To check a property's type, select it, and then consult the value of the Type field in the Properties view.
As an alternative, take a look at the property's icon.
We know all the properties mapped by the service above are string properties because of their S
icon.
Every data type is assigned a unique icon. Learn more about Gloop data types here.
Because the service invocation will be logged programmatically, it is up to the developer to map the required values for the operation. In most cases, such as when logging data via an endpoint, Martini will automatically populate the resulting Tracker document for you with sensible, default values.
Invoke the data-logging service
After configuring this service, you will be able to invoke it, causing a Tracker document to be added to the Tracker search index. This page will invoke the service via the Martini IDE. To do this:
- Open the service by double-clicking it from the Navigator.
- Click the run button on the toolbar.
- Provide the inputs required by the service.
- Click Run.
Set input properties to avoid errors
All parameters of the function, save for senderId
and receiverId
, are required.
This means to avoid exceptions, the service must be run (at a minimum) with all other properties populated.
We used the following values for this tutorial, but you can use your own values if you like.
Property | Value |
---|---|
internalId |
b9f7b200-cda3-4e57-8272-r34e86a6c6e6 |
externalId |
1350667274351 |
documentTypeId |
tutorial |
senderId |
localhost |
receiverId |
localhost |
content |
This invocation was logged via a function. |
stateName |
Completed |
To import these values:
- Open the service inputs dialog.
-
Copy the following JSON text to your clipboard:
1 2 3 4 5 6 7 8 9
{ "internalId": "b9f7b200-cda3-4e57-8272-r34e86a6c6e", "externalId": "1350667274351", "documentTypeId": "tutorial", "senderId": "localhost", "receiverId": "localhost", "stateName": "Completed", "content": "This invocation was logged via a function." }
-
Click Import > From Clipboard.
View the document
After a few seconds, Martini will commit the document to the index. This means the Tracker document produced by your call to the function can now be viewed. To do this:
- Open the Tracker view by clicking the Tracker button on the toolbar.
- If you don't have other logging operations ongoing, your document will appear as the top most entry. If you're having a hard time finding your document, use the search bar.
- Double click your document in order to view more details.
-
You can also use the invoke monitor for this purpose. However, the invoke monitor is better suited for monetization and throttling. ↩