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

feat: Add OpenTelemetry instrumentation for ActiveJ HTTP server #13335

Merged
merged 57 commits into from
Feb 27, 2025

Conversation

kcsurapaneni
Copy link
Contributor

Overview

This PR introduces OpenTelemetry instrumentation for the ActiveJ framework, enabling distributed tracing and context propagation for ActiveJ-based HTTP servers. The changes allow developers to monitor and debug ActiveJ applications in distributed systems by capturing trace context from incoming requests and propagating it through responses.

Key Features

  • Distributed Tracing: Automatically propagates trace context using the traceparent header.
  • HTTP Attribute Extraction: Captures detailed HTTP attributes (e.g., method, path, headers, status code) for enriched telemetry data.
  • Error Handling: Maps exceptions to appropriate HTTP status codes and associates them with spans for better error visibility.

Changes Included

  1. Instrumentation:

    • ActiveJHttpServerConnectionInstrumentation: Instruments the serve method of ActiveJ servlets to capture and propagate trace context.
  2. Testing:

    • Added test cases to validate tracing behavior and ensure compliance with W3C Trace Context.
  3. Documentation:

    • Added README with details about the instrumentation, usage, and configuration.

Testing

  • All existing tests pass successfully.
  • New test cases have been added to validate:
    • Trace context propagation via the traceparent header.
    • Correctness of HTTP attribute extraction.
    • Error handling and span enrichment.

Benefits

  • Observability for ActiveJ applications, making it easier to monitor and debug distributed systems.
  • Seamless integration with OpenTelemetry exporters (e.g., Jaeger, Zipkin, HyperDX) for visualizing traces.

Related Issues

Closes #13202

Acknowledgments

This implementation was inspired by and adapted from the ActiveJ framework codebase. Special thanks to the ActiveJ community for their excellent work and contributions.

@kcsurapaneni kcsurapaneni requested a review from a team as a code owner February 18, 2025 06:46
Copy link

linux-foundation-easycla bot commented Feb 18, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

…nabling distributed tracing and context propagation for ActiveJ-based HTTP servers
Copy link
Member

@jaydeluca jaydeluca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will want integration tests for any new instrumentation

@kcsurapaneni
Copy link
Contributor Author

we will want integration tests for any new instrumentation

@jaydeluca I have added test cases and resolved most of the workflow job failures. But, still there are couple of them are failing and not able to understand the cause after checking the raw logs as well. Could you please help me to understand what causing them to failure so that I can fix them. Thank you!

CC: @trask @laurit

@laurit
Copy link
Contributor

laurit commented Feb 19, 2025

See https://scans.gradle.com/s/dy73bc67fptxo/tests/task/:instrumentation:activej-http-6.0:javaagent:test/details/(N%2FA)/Gradle%20Test%20Executor%2045?top-execution=1
Framework seems to require java 17

@kcsurapaneni
Copy link
Contributor Author

See https://scans.gradle.com/s/dy73bc67fptxo/tests/task/:instrumentation:activej-http-6.0:javaagent:test/details/(N%2FA)/Gradle%20Test%20Executor%2045?top-execution=1 Framework seems to require java 17

@laurit Thanks for the link. So, all the agents should support minimum java 8?

@laurit
Copy link
Contributor

laurit commented Feb 19, 2025

@laurit Thanks for the link. So, all the agents should support minimum java 8?

If the framework does not support java 8 then you shouldn't run the tests for it with java 8. Add

otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}

@kcsurapaneni
Copy link
Contributor Author

@laurit Thanks for the link. So, all the agents should support minimum java 8?

If the framework does not support java 8 then you shouldn't run the tests for it with java 8. Add

otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}

Thanks for the help! @laurit . Build looks good now. Please review

renovate bot and others added 12 commits February 26, 2025 00:47
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…3380)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…13372)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Trask Stalnaker <[email protected]>
…h2-http to v1.33.0 (open-telemetry#13387)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…h2-http to v1.33.1 (open-telemetry#13395)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
open-telemetry#13397)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@kcsurapaneni kcsurapaneni requested a review from laurit February 26, 2025 19:07
@trask trask merged commit 8e09d59 into open-telemetry:main Feb 27, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test native This label can be applied to PRs to trigger them to run native tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context Propagation for ActiveJ Applications Using OpenTelemetry Java Agent Instrumentation
10 participants