From 692e0f2c752a4c1fd7f2d4a2809ad835d19d2f76 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 21 Nov 2025 19:38:56 +0100 Subject: [PATCH 1/4] cleanup javaagent example --- .../oats/docker-compose.yml | 4 +- doc-snippets/spring-starter/build.gradle.kts | 1 - javaagent/README.md | 17 -- javaagent/docker-compose.yml | 11 +- javaagent/sdk-config.yaml | 248 ------------------ spring-native/build.gradle.kts | 3 - 6 files changed, 2 insertions(+), 282 deletions(-) delete mode 100644 javaagent/sdk-config.yaml diff --git a/doc-snippets/extensions-minimal/oats/docker-compose.yml b/doc-snippets/extensions-minimal/oats/docker-compose.yml index dc6be5cfe4..e1b2e2f75e 100644 --- a/doc-snippets/extensions-minimal/oats/docker-compose.yml +++ b/doc-snippets/extensions-minimal/oats/docker-compose.yml @@ -7,7 +7,5 @@ services: environment: OTEL_SERVICE_NAME: "extensions-minimal-test-app" OTEL_EXPORTER_OTLP_ENDPOINT: http://lgtm:4318 - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://lgtm:4318/v1/traces - OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf ports: - - "8080:8080" \ No newline at end of file + - "8080:8080" diff --git a/doc-snippets/spring-starter/build.gradle.kts b/doc-snippets/spring-starter/build.gradle.kts index 8152486241..ff97d15c09 100644 --- a/doc-snippets/spring-starter/build.gradle.kts +++ b/doc-snippets/spring-starter/build.gradle.kts @@ -20,7 +20,6 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter") - implementation("io.opentelemetry.contrib:opentelemetry-samplers:1.51.0-alpha") } springBoot { diff --git a/javaagent/README.md b/javaagent/README.md index ab3a0f7caf..e01cf578f5 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -44,20 +44,3 @@ curl http://localhost:8080/ping ``` Watch for spans, metrics, and logs in the Collector log output. - -## Declarative Configuration - -By default, this example uses the [environment variable configuration schema](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md) to configure the SDK. However, it also includes [sdk-config.yaml](./sdk-config.yaml) which demonstrates how the [declarative configuration](https://opentelemetry.io/docs/specs/otel/configuration/#declarative-configuration) scheme can be used to configure the SDK based on a YAML configuration file instead. - -`sdk-config.yaml` extends the [opentelemetry-configuration sdk-config.yaml](https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-config.yaml) template, demonstrating: - -- Configuration of instrumentation (see `.instrumentation.java`) -- Configuration of [rule-based routing sampler](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/samplers) (see `.tracer_provider.sampler.parent_based.root`) - -To use declarative configuration instead of the environment variable scheme, add the following before starting the application and Collector: - -```shell -export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml -``` - -Note: toggling declarative configuration causes the env var configuration scheme to be ignored completely. However, there is support for [env var substitution](https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution) within configuration files. diff --git a/javaagent/docker-compose.yml b/javaagent/docker-compose.yml index 6ccd6484fe..5888259cbc 100644 --- a/javaagent/docker-compose.yml +++ b/javaagent/docker-compose.yml @@ -4,18 +4,9 @@ services: build: ./ environment: OTEL_SERVICE_NAME: "agent-example-app" - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: "http://collector:4318/v1/traces" - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: "http://collector:4318/v1/metrics" - OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: "http://collector:4318/v1/logs" - # Logs are disabled by default - OTEL_LOGS_EXPORTER: "otlp" - # Optional specify file configuration instead of using environment variable scheme - # To use, call "export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml" before calling docker compose up - OTEL_EXPERIMENTAL_CONFIG_FILE: + OTEL_EXPORTER_OTLP_ENDPOINT: "http://collector:4318" ports: - "8080:8080" - volumes: - - ./sdk-config.yaml:/sdk-config.yaml depends_on: - collector collector: diff --git a/javaagent/sdk-config.yaml b/javaagent/sdk-config.yaml deleted file mode 100644 index 253c37f647..0000000000 --- a/javaagent/sdk-config.yaml +++ /dev/null @@ -1,248 +0,0 @@ -# Copy of https://github.com/open-telemetry/opentelemetry-configuration/blob/v1.0.0-rc.2/examples/sdk-config.yaml -# with the following changes: -# - OpenTelemetry Java Agent properties added at .instrumentation.java. -# - OTLP exporter endpoints modified to point to http://collector:4318/v1/{path} to export to collector from docker-compose.yml -# - .tracer_provider.sampler.parent_based.root set to rule_based_routing sampler to demonstrate turning off sampling for spring boot actuator endpoints. - -# -# sdk-config.yaml is a typical starting point for configuring the SDK, including exporting to -# localhost via OTLP. - -# NOTE: With the exception of env var substitution syntax (i.e. ${MY_ENV}), SDKs ignore -# environment variables when interpreting config files. This including ignoring all env -# vars defined in https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/. - -# The file format version. -file_format: "1.0-rc.2" - -# Configure if the SDK is disabled or not. This is not required to be provided to ensure the SDK isn't disabled, the default value when this is not provided is for the SDK to be enabled. -disabled: false - -# Configure resource for all signals. -resource: - # Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. - # Entries must contain .name nand .value, and may optionally include .type, which defaults ot "string" if not set. The value must match the type. Values for .type include: string, bool, int, double, string_array, bool_array, int_array, double_array. - attributes: - - name: service.name - value: unknown_service - -# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. -attribute_limits: - # Configure max attribute value size. - attribute_value_length_limit: - # Configure max attribute count. - attribute_count_limit: 128 - -# Configure text map context propagators. -propagator: - # Configure the set of propagators to include in the composite text map propagator. - composite: - - tracecontext: - - baggage: - -# Configure tracer provider. -tracer_provider: - # Configure span processors. - processors: - - # Configure a batch span processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - schedule_delay: 5000 - # Configure maximum allowed time (in milliseconds) to export data. - export_timeout: 30000 - # Configure maximum queue size. - max_queue_size: 2048 - # Configure maximum batch size. - max_export_batch_size: 512 - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: http/protobuf - # Configure endpoint. - endpoint: http://collector:4318/v1/traces - # Configure certificate. - certificate: - # Configure mTLS private client key. - client_key: - # Configure mTLS client certificate. - client_certificate: - # Configure compression. - compression: gzip - # Configure max time (in milliseconds) to wait for each export. - timeout: 10000 - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure span limits. See also attribute_limits. - limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - attribute_value_length_limit: # Configure max span attribute count. Overrides attribute_limits.attribute_count_limit. - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - attribute_count_limit: 128 - # Configure max span event count. - event_count_limit: 128 - # Configure max span link count. - link_count_limit: 128 - # Configure max attributes per span event. - event_attribute_count_limit: 128 - # Configure max attributes per span link. - link_attribute_count_limit: 128 - # Configure the sampler. - sampler: - # Configure sampler to be parent_based. - parent_based: - # Configure the parent_based sampler's root sampler to be rule_based_routing sampler from https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/samplers. - root: - rule_based_routing: - # Fallback to the always_on sampler if the criteria is not met. - fallback_sampler: - always_on: - # Only apply to SERVER spans. - span_kind: SERVER - rules: - # Drop spans where url.path matches the regex /actuator.* (i.e. spring boot actuator endpoints). - - action: DROP - attribute: url.path - pattern: /actuator.* - # Configure remote_parent_sampled sampler. - remote_parent_sampled: - # Configure sampler to be always_on. - always_on: {} - # Configure remote_parent_not_sampled sampler. - remote_parent_not_sampled: - # Configure sampler to be always_off. - always_off: {} - # Configure local_parent_sampled sampler. - local_parent_sampled: - # Configure sampler to be always_on. - always_on: {} - # Configure local_parent_not_sampled sampler. - local_parent_not_sampled: - # Configure sampler to be always_off. - always_off: {} - -# Configure meter provider. -meter_provider: - # Configure metric readers. - readers: - - # Configure a periodic metric reader. - periodic: - # Configure delay interval (in milliseconds) between start of two consecutive exports. - interval: 60000 - # Configure maximum allowed time (in milliseconds) to export data. - timeout: 30000 - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: http/protobuf - # Configure endpoint. - endpoint: http://collector:4318/v1/metrics - # Configure certificate. - certificate: - # Configure mTLS private client key. - client_key: - # Configure mTLS client certificate. - client_certificate: - # Configure compression. - compression: gzip - # Configure max time (in milliseconds) to wait for each export. - timeout: 10000 - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure temporality preference. - temporality_preference: cumulative - # Configure default histogram aggregation. - default_histogram_aggregation: explicit_bucket_histogram - -# Configure logger provider. -logger_provider: - # Configure log record processors. - processors: - - # Configure a batch log record processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - schedule_delay: 1000 - # Configure maximum allowed time (in milliseconds) to export data. - export_timeout: 30000 - # Configure maximum queue size. - max_queue_size: 2048 - # Configure maximum batch size. - max_export_batch_size: 512 - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: http/protobuf - # Configure endpoint. - endpoint: http://collector:4318/v1/logs - # Configure certificate. - certificate: - # Configure mTLS private client key. - client_key: - # Configure mTLS client certificate. - client_certificate: - # Configure compression. - compression: gzip - # Configure max time (in milliseconds) to wait for each export. - timeout: 10000 - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure log record limits. See also attribute_limits. - limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - attribute_value_length_limit: # Configure max log record attribute count. Overrides attribute_limits.attribute_count_limit. - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - attribute_count_limit: 128 - - -# Configure instrumentation. -instrumentation: - # Configure OpenTelemetry Java Agent. A standard translation process is applied to convert the - # flat system properties / env var configuration scheme from https://opentelemetry.io/docs/zero-code/java/agent/ - # to the structured scheme used by declarative configuration: - # - # - Resolve properties starting with "otel.instrumentation." - # - Strip the "otel.instrumentation." prefix. - # - Split the remaining property string on "." character to break into segments - # - Starting at .instrumentation.java, follow N-1 segments to resolve the leaf node to read the property from - # - Read segment N from the resolved leaf node - # - # For example, the property "otel.instrumentation.common.default-enabled" is resolved by - # reading: .instrumentation.java.common.default-enabled - # - # Some system properties / env vars cannot be configured via declarative configuration, normally - # because they are resolved in the application lifecycle before declarative configuration is - # available. The set of unsupported properties includes: - # - otel.javaagent.enabled - # - otel.javaagent.configuration-file - # - otel.javaagent.extensions - # - otel.javaagent.logging - # - otel.resource.providers.[provider].enabled - # - # A sample set of OpenTelemetry Java Agent are shown below, with env var substitution references - # reflecting agent defaults. For properties that are not referenced, consult the translation - # steps discussed above. - java: - common: - default-enabled: true - # Configuration java-util-logging instrumentation. Properties adapted from: - # https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/java-util-logging/javaagent - java-util-logging: - enabled: true - experimental-log-attributes: false - # Configuration logback-appender instrumentation. Properties adapted from: - # https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-appender-1.0/javaagent - logback-appender: - enabled: true - experimental-log-attributes: false - experimental: - capture-code-attributes: false - capture-marker-attributes: false - capture-key-value-pair-attributes: false - capture-logger-context-attributes: false - capture-arguments: false - capture-mdc-attributes: false diff --git a/spring-native/build.gradle.kts b/spring-native/build.gradle.kts index 467ab5359b..eb4db24cd2 100644 --- a/spring-native/build.gradle.kts +++ b/spring-native/build.gradle.kts @@ -23,7 +23,4 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-data-jdbc") implementation("com.h2database:h2") implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter") - - // for otelCustomizer in Application.java - implementation("io.opentelemetry.contrib:opentelemetry-samplers:1.51.0-alpha") } From 8b6fafc588484ae20696186649b7d2ee951e0d01 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 21 Nov 2025 19:47:06 +0100 Subject: [PATCH 2/4] cleanup javaagent example --- doc-snippets/spring-starter/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/doc-snippets/spring-starter/build.gradle.kts b/doc-snippets/spring-starter/build.gradle.kts index ff97d15c09..8152486241 100644 --- a/doc-snippets/spring-starter/build.gradle.kts +++ b/doc-snippets/spring-starter/build.gradle.kts @@ -20,6 +20,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter") + implementation("io.opentelemetry.contrib:opentelemetry-samplers:1.51.0-alpha") } springBoot { From 4a6bc88252026b84b351c8a2a6f59e10a062d72c Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 21 Nov 2025 19:53:59 +0100 Subject: [PATCH 3/4] cleanup javaagent example --- declarative-configuration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/declarative-configuration/README.md b/declarative-configuration/README.md index 50d0afaf30..e0c41ed838 100644 --- a/declarative-configuration/README.md +++ b/declarative-configuration/README.md @@ -20,4 +20,4 @@ export OTEL_EXPERIMENTAL_CONFIG_FILE=$(pwd)/otel-sdk-config.yaml Observe how data is printed to the console as configured in [otel-sdk-config.yaml](./otel-sdk-config.yaml). -For use with the OpenTelemetry Java Agent, see [Java Agent declarative configuration](../javaagent/README.md#declarative-configuration). +For use with the OpenTelemetry Java Agent, see [Java Agent declarative configuration](../javaagent-declarative-configuration). From 34e362c33d1c9eec0952700efac5e6bdc417b539 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 21 Nov 2025 19:56:36 +0100 Subject: [PATCH 4/4] cleanup javaagent example --- spring-native/build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-native/build.gradle.kts b/spring-native/build.gradle.kts index eb4db24cd2..467ab5359b 100644 --- a/spring-native/build.gradle.kts +++ b/spring-native/build.gradle.kts @@ -23,4 +23,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-data-jdbc") implementation("com.h2database:h2") implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter") + + // for otelCustomizer in Application.java + implementation("io.opentelemetry.contrib:opentelemetry-samplers:1.51.0-alpha") }