Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Jenkins OpenTelemetry with Gradle OpenTelemetry #850

Closed
cyrille-leclerc opened this issue May 22, 2024 · 5 comments
Closed

Integrate Jenkins OpenTelemetry with Gradle OpenTelemetry #850

cyrille-leclerc opened this issue May 22, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@cyrille-leclerc
Copy link
Contributor

What feature do you want to see added?

Gradle supports OTel instrumentation through the https:/craigatk/opentelemetry-gradle-plugin
We want the same OpenTelemetry integration of Gradle builds with Jenkins as we have with Maven builds.

Upstream changes

Hopefully no change if the OpenTelemetry Gradle Plugin supports context propagation making sense of the TRACEPARENT and TRACESTATE environment variables.
Hopefully it's just documentation.

Are you interested in contributing this feature?

Yes.
@craigatk would you be interested in this integration that may just be documentation?

@cyrille-leclerc cyrille-leclerc added the enhancement New feature or request label May 22, 2024
@craigatk
Copy link

Sure, I'd be happy to update the OpenTelemetry Gradle plugin to more seamlessly integrate with the Jenkins OpenTelemetry plugin.

Currently the Gradle plugin looks for the parent trace ID and parent span ID with environment variables (docs), and I can add the specific environment variable names this Jenkins plugin uses.

For grabbing the parent trace ID and parent span ID in the Gradle plugin, is there documentation and/or code that lists what's in the TRACEPARENT and TRACESTATE environment variables published by the Jenkins plugin?

@craigatk
Copy link

Ahh I think I found it in the docs, looks like the Jenkins plugin is already exporting the same TRACE_ID and SPAN_ID environment variables that the Gradle plugin is looking for https:/jenkinsci/opentelemetry-plugin/blob/main/docs/job-traces.md#environment-variables-for-trace-context-propagation-and-integrations

So this may just be a documentation update, as you mentioned.

@cyrille-leclerc
Copy link
Contributor Author

cyrille-leclerc commented May 22, 2024

Thanks Craig!

TRACEPARENT and TRACESTATE follow the https://www.w3.org/TR/trace-context/ spec with the subtle nuance of being upper case rather than lower case.
The OTel community discusses the standardization of hese environment variables in

The Java code we use to parse TRACEPARENT and TRACESTATE is provided by the OTel SDK:

    TextMapGetter<Map<String, String>> toUpperCaseTextMapGetter = new ToUpperCaseTextMapGetter();
    io.opentelemetry.context.Context context =
        openTelemetrySdkService
            .getPropagators()
            .getTextMapPropagator()
            .extract(
                io.opentelemetry.context.Context.current(),
                System.getenv(),
                toUpperCaseTextMapGetter);

https:/open-telemetry/opentelemetry-java-contrib/blob/0deabdde108c544b1b6a3642578acb7fe88fc294/maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java#L138-L146

You can find in many CI/CD tools that support TRACEPARENT and TRACESTATE, including:

@kuisathaverat
Copy link
Contributor

pytest-otel also support it

@cyrille-leclerc
Copy link
Contributor Author

Works out of the box
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants