avioconsulting / mule-opentelemetry-module

Mule Extension to generate OpenTelemetry traces and metrics
https://avioconsulting.github.io/mule-opentelemetry-module/
BSD 2-Clause "Simplified" License
23 stars 8 forks source link

Simplify HTTP headers injection #12

Open manikmagar opened 2 years ago

manikmagar commented 2 years ago

While auto-injection isn't supported (see Limitations ), the HTTP Request Context Injection approach requires users to be aware of what header entries need to be added.

<http:request-config name="HTTP_Request_configuration_App2" doc:name="HTTP Request configuration" doc:id="23878620-099a-4c33-8a3a-31cdc4f912d1">
    <http:request-connection host="localhost" port="8082" />
    <http:default-headers >
      <http:default-header key="traceparent" value="#[(vars.OTEL_TRACE_CONTEXT.traceparent as String) default '']" /> 
    </http:default-headers>
  </http:request-config>

Depending on the propagators configured, the list of header entries could vary. This need for explicit entries needs to be avoided.

We could provide a dataweave module function ,eg otel.getHttpHeaders() which returns HTTP default headers compatible map, that users could add in default headers -

<http:request-config name="HTTP_Request_configuration_App2" doc:name="HTTP Request configuration"defaultHeaders="#[otel.getHttpHeaders()]">
        <http:request-connection host="localhost" port="8082" />
    </http:request-config>
manikmagar commented 2 years ago

This doesn't seem to be feasible. The RequestHeader representing the default header entries, does not have a public constructor or setters.

zedwards14276 commented 5 months ago

Hi @manikmagar I was trying to set the traceparent as a logging variable but Anypoint Studio isn't able to find the properties for OTEL_TRACE_CONTEXT.

I was trying to follow the instructions here: https://medium.com/@jromasanta/part-2-integrating-dynatrace-using-mulesoft-4-22da37c24d58

I've tried using 1.5.0 and 2.0.0-M3 but neither one is working. What am I doing wrong here?

image

manikmagar commented 5 months ago

Hi @zedwards14276, I assume this is a warning in the Anypoint Studio only. You can safely ignore that since that variable is inserted by the module at runtime.