Repository navigation
Add Elastic Otel Java agent #1360
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff2f649
Add Elastic Otel Agent
jackshirazi dcbfda1
typos
jackshirazi 61ad9ae
licenses
jackshirazi 9ba1f4f
corrections from feedback
jackshirazi ab78843
address stokpop feedback, only elastic-otel initiates agent
jackshirazi 3a56de2
troubleshooting update following stokpop feedback
jackshirazi 4045ce0
fix stokpop feedback test failures
jackshirazi d7114ba
fix stokpop feedback on authorization key, skipped test & comments
jackshirazi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Elastic OTel Java Agent Framework | ||
|
|
||
| The Elastic OTel Java Agent Framework causes an application to be automatically configured to work with the [Elastic Distribution of OpenTelemetry Java][]. | ||
|
|
||
| <table> | ||
| <tr> | ||
| <td><strong>Detection Criterion</strong></td> | ||
| <td>Existence of a bound Elastic OTel service. The service must have a name containing, or a label or tag matching, <code>elastic-otel</code>, <code>edot-java</code>, or <code>elastic-edot</code>, and the combined service and environment configuration must provide an OTLP endpoint plus authentication credentials. The framework can also be enabled explicitly with <code>ELASTIC_OTEL_AGENT</code> when the same required configuration is present.</td> | ||
| </tr> | ||
| <tr> | ||
| <td><strong>Tags</strong></td> | ||
| <td><tt>elastic-otel-javaagent=<version></tt></td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| Tags are printed to standard output by the buildpack detect script. | ||
|
|
||
| ## User-Provided Service | ||
|
|
||
| Users can provide their own Elastic OTel service. A user-provided service must have a name containing or a tag matching `elastic-otel`, `edot-java`, or `elastic-edot` so that the framework configures the application with the Elastic OTel Java agent. | ||
|
|
||
| The credential payload can contain the following entries. | ||
|
|
||
| | Name | Description | | ||
| | ---- | ----------- | | ||
| | `otel.exporter.otlp.endpoint` | The OTLP endpoint for your Elastic deployment or EDOT Collector. Aliases: `otlp_endpoint`, `otlpEndpoint`, `endpoint`. | | ||
| | `otel.exporter.otlp.headers` | Explicit OTLP headers, for example `Authorization=ApiKey <key>`. If present, this takes precedence over derived authentication headers. | | ||
| | `api_key` | Elastic API key. Converted to `otel.exporter.otlp.headers=Authorization=ApiKey <key>`. | | ||
| | `secret_token` | Bearer token. Converted to `otel.exporter.otlp.headers=Authorization=Bearer <token>`. | | ||
| | `otel.*` | Any additional OpenTelemetry configuration applied as JVM system properties. | | ||
| | `elastic.otel.*` | Any additional Elastic OTel configuration applied as JVM system properties. | | ||
|
|
||
| ### Creating an Elastic OTel User-Provided Service | ||
|
|
||
| Example minimal configuration: | ||
|
|
||
| ``` | ||
| cf cups my-elastic-otel-service -p '{"otel.exporter.otlp.endpoint":"https://my-deployment.ingest.us-west1.gcp.cloud.es.io","api_key":"my-api-key"}' | ||
| ``` | ||
|
|
||
| Example configuration with explicit OTLP headers and resource attributes: | ||
|
|
||
| ``` | ||
| cf cups my-elastic-otel-service -p '{"otel.exporter.otlp.endpoint":"https://my-deployment.ingest.us-west1.gcp.cloud.es.io","otel.exporter.otlp.headers":"Authorization=ApiKey my-api-key","otel.resource.attributes":"deployment.environment.name=production"}' | ||
| ``` | ||
|
|
||
| Bind your application to the service using: | ||
|
|
||
| `cf bind-service my-app-name my-elastic-otel-service` | ||
|
|
||
| or use the `services` block in the application manifest file. | ||
|
|
||
| ## Configuration | ||
|
|
||
| For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][]. | ||
|
|
||
| The framework uses the dependency version configured in `manifest.yml`. | ||
|
|
||
| | Name | Description | | ||
| | ---- | ----------- | | ||
| | `version` | The version of Elastic OTel Java agent to use. The current buildpack manifest uses the `elastic-otel-javaagent` dependency. | | ||
|
|
||
| The framework sets `otel.service.name` from service credentials, then `OTEL_SERVICE_NAME`, then `VCAP_APPLICATION.application_name`, using the first configured value. It also sets `deployment.environment.name` from `VCAP_APPLICATION.space_name` when `otel.resource.attributes` is not configured. Generic OTLP environment variables do not select the Elastic distribution by themselves; set `ELASTIC_OTEL_AGENT` to choose it explicitly. | ||
|
|
||
| Authentication headers are provided through `OTEL_EXPORTER_OTLP_HEADERS` rather than a JVM system property. When the headers come from service credentials, the framework resolves them from `VCAP_SERVICES` when the application starts. This keeps credentials out of the JVM command line and allows credential rotation with an application restart instead of a restage. | ||
|
|
||
| > **Warning** | ||
| > Do not bind this framework alongside the Elastic APM Agent, OpenTelemetry Javaagent, Splunk OTel Java Agent, or another Java agent framework for the same application. Running multiple Java agents in the same JVM can cause duplicate telemetry or conflicting instrumentation. | ||
|
|
||
| ## Troubleshooting: Multiple Agents or Wrong Agent | ||
|
|
||
| - **Elastic and Splunk agents both start:** `OTEL_EXPORTER_OTLP_ENDPOINT` is set as an environment variable during staging. Also set `ELASTIC_OTEL_AGENT=true`, or put the endpoint in the service credentials instead. | ||
| - **Upstream OpenTelemetry agent starts instead of Elastic:** The Elastic service lacks authentication credentials. Add `api_key` or `otel.exporter.otlp.headers`. | ||
| - **Elastic and OpenTelemetry agents both start:** An `otel-collector` service or another `otel`-named or `otel`-tagged service is also bound. Unbind it. | ||
| - **Telemetry does not reach Elastic:** `OTEL_EXPORTER_OTLP_ENDPOINT`, set as an environment variable during staging, overrides the endpoint from the service binding. Remove it, or make sure it points to Elastic. | ||
|
|
||
| ## Migration From Elastic APM Agent | ||
|
|
||
| The Elastic OTel Java agent uses OTLP configuration. It does not use Elastic APM agent settings such as `server_url` or `secret_token` with the `elastic.apm.*` prefix. | ||
|
|
||
| When migrating, create a new service binding named or tagged for Elastic OTel and provide an OTLP endpoint plus `otel.exporter.otlp.headers` or `api_key`. | ||
|
|
||
| [Configuration and Extension]: ../README.md#configuration-and-extension | ||
| [Elastic Distribution of OpenTelemetry Java]: https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/java | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.