We have a workflow where we kick off a Camunda process instance via a RESTful endpoint, using Camunda’s Java API. We use Microsoft Azure as our cloud provider, so our logging framework is Azure Application Insights.
In Application Insights, all RESTful API calls are associated with an operation ID, i.e. an identifier that can be used to correlate log telemetry between different operations. When our API is called, we’d like all the log messages generated by the Java delegates invoked by the process instance to be visible under that same operation ID. Currently, the log messages from our process instance are visible in App Insights, but not associated with the operation ID of the RESTful API call. This makes it harder to track those messages.
Is there a way to pass some kind of telemetry ID to a Camunda 7 process instance at startup for purposes of log correlation?
For anyone looking at this, we solved the problem by using process instance variables and the OpenTelemetry Java API. In our code that kicks off the process instances, we did something like the following.
For our delegates, we have an abstract base class named WorkflowJavaDelegate that extends the Camunda JavaDelegate interface. The WorkflowJavaDelegate class’s implementation of the execute method from the interface calls an abstract method named doExecute, which each derived class defines. In that WorkflowJavaDelegate class, we fetch the variables from the DelegateExecution object, and use them to create OpenTelemetry spans.