From d0b6ade2a4c6922308a62e92158a6efc04074871 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Fri, 20 Sep 2024 17:06:23 -0500 Subject: [PATCH 01/10] Demosntrate declarative config 0.3 with otel java agent --- build.gradle.kts | 1 + javaagent/README.md | 2 +- javaagent/build.gradle.kts | 2 +- javaagent/docker-compose.yml | 4 +- javaagent/sdk-config.yaml | 289 ++++++++++++++++++++++++++++++++++- 5 files changed, 290 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3d76309f85..9186e45ab2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,7 @@ subprojects { version = "0.1.0-SNAPSHOT" repositories { + mavenLocal() mavenCentral() } diff --git a/javaagent/README.md b/javaagent/README.md index 69b414c8d7..15dca3078c 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -52,7 +52,7 @@ By default, this example uses the [environment variable configuration schema](ht To use file configuration instead of the environment variable scheme, add the following before starting the application and collector: ```shell -export OTEL_CONFIG_FILE=/sdk-config.yaml +export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml ``` Note that toggling file configuration causes the environment variable configuration scheme to be ignored completely. However, there is support for environment variable substitution within configuration files. diff --git a/javaagent/build.gradle.kts b/javaagent/build.gradle.kts index c6d2ce523b..be3a3e96ea 100644 --- a/javaagent/build.gradle.kts +++ b/javaagent/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { //spring modules implementation("org.springframework.boot:spring-boot-starter-web") - agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.8.0") + agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.9.0-SNAPSHOT") } val copyAgent = tasks.register("copyAgent") { diff --git a/javaagent/docker-compose.yml b/javaagent/docker-compose.yml index a167ca0fd2..8ee6122bf3 100644 --- a/javaagent/docker-compose.yml +++ b/javaagent/docker-compose.yml @@ -8,8 +8,8 @@ services: # Logs are disabled by default OTEL_LOGS_EXPORTER: "otlp" # Optional specify file configuration instead of using environment variable scheme - # To use, call "export OTEL_CONFIG_FILE=/sdk-config.yaml" before calling docker compose up - OTEL_CONFIG_FILE: + # To use, call "export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml" before calling docker compose up + OTEL_EXPERIMENTAL_CONFIG_FILE: /sdk-config.yaml ports: - "8080:8080" volumes: diff --git a/javaagent/sdk-config.yaml b/javaagent/sdk-config.yaml index b20c816a45..0c84e5e695 100644 --- a/javaagent/sdk-config.yaml +++ b/javaagent/sdk-config.yaml @@ -2,14 +2,15 @@ file_format: "0.1" resource: attributes: - service.name: agent-example-app + - name: service.name + value: agent-example-app logger_provider: processors: - batch: exporter: otlp: - endpoint: http://collector:4318 + endpoint: http://collector:4318/v1/logs protocol: http/protobuf tracer_provider: @@ -17,15 +18,16 @@ tracer_provider: - batch: exporter: otlp: - endpoint: http://collector:4318 + endpoint: http://collector:4318/v1/traces protocol: http/protobuf meter_provider: readers: - periodic: + interval: 5000 exporter: otlp: - endpoint: http://collector:4318 + endpoint: http://collector:4318/v1/metrics protocol: http/protobuf # Example of how to use view to drop a metric which isn't needed. # This configuration is not available with the environment variable configuration scheme. @@ -36,3 +38,282 @@ meter_provider: stream: aggregation: drop: + +instrumentation: + java: + common: + default-enabled: true + methods: + enabled: true + external-annotations: + enabled: true + akka-actor: + enabled: true + akka-http: + enabled: true + axis2: + enabled: true + camel: + enabled: true + cassandra: + enabled: true + cxf: + enabled: true + apache-dbcp: + enabled: true + apache-dubbo: + enabled: true + geode: + enabled: true + apache-httpasyncclient: + enabled: true + apache-httpclient: + enabled: true + kafka: + enabled: true + jsf-myfaces: + enabled: true + pekko-actor: + enabled: true + pekko-http: + enabled: true + pulsar: + enabled: true + rocketmq-client: + enabled: true + apache-shenyu: + enabled: true + struts: + enabled: true + tapestry: + enabled: true + tomcat: + enabled: true + wicket: + enabled: true + armeria: + enabled: true + async-http-client: + enabled: true + aws-lambda: + enabled: true + aws-sdk: + enabled: true + azure-core: + enabled: true + clickhouse: + enabled: true + couchbase: + enabled: true + c3p0: + enabled: true + dropwizard-views: + enabled: true + dropwizard-metrics: + enabled: true + grizzly: + enabled: true + jersey: + enabled: true + jetty: + enabled: true + jetty-httpclient: + enabled: true + metro: + enabled: true + jsf-mojarra: + enabled: true + vertx-http-client: + enabled: true + vertx-kafka-client: + enabled: true + vertx-redis-client: + enabled: true + vertx-rx-java: + enabled: true + vertx-sql-client: + enabled: true + vertx-web: + enabled: true + elasticsearch-transport: + enabled: true + elasticsearch-rest: + enabled: true + finagle-http: + enabled: true + guava: + enabled: true + google-http-client: + enabled: true + gwt: + enabled: true + grails: + enabled: true + graphql-java: + enabled: true + grpc: + enabled: true + hibernate: + enabled: true + hibernate-reactive: + enabled: true + hikaricp: + enabled: true + influxdb: + enabled: true + java-http-client: + enabled: true + http-url-connection: + enabled: true + jdbc: + enabled: true + jdbc-datasource: + enabled: true + rmi: + enabled: true + runtime-telemetry: + enabled: false + servlet: + enabled: true + executors: + enabled: true + java-util-logging: + enabled: true + javalin: + enabled: true + jaxrs-client: + enabled: true + jaxrs: + enabled: true + jaxws: + enabled: true + jboss-logmanager-appender: + enabled: true + jboss-logmanager-mdc: + enabled: true + jms: + enabled: true + jodd-http: + enabled: true + jsp: + enabled: true + kubernetes-client: + enabled: true + ktor: + enabled: true + kotlinx-coroutines: + enabled: true + log4j-appender: + enabled: true + log4j-mdc: + enabled: true + log4j-context-data: + enabled: true + logback-appender: + enabled: true + logback-mdc: + enabled: true + micrometer: + enabled: true + mongo: + enabled: true + mybatis: + enabled: true + hystrix: + enabled: true + netty: + enabled: true + okhttp: + enabled: true + liberty: + enabled: true + opentelemetry-extension-annotations: + enabled: true + opentelemetry-instrumentation-annotations: + enabled: true + opentelemetry-api: + enabled: true + oracle-ucp: + enabled: true + oshi: + enabled: true + play: + enabled: true + play-ws: + enabled: true + quarkus: + enabled: true + quartz: + enabled: true + r2dbc: + enabled: true + rabbitmq: + enabled: true + ratpack: + enabled: true + rxjava: + enabled: true + reactor: + enabled: true + reactor-kafka: + enabled: true + reactor-netty: + enabled: true + jedis: + enabled: true + lettuce: + enabled: true + rediscala: + enabled: true + redisson: + enabled: true + restlet: + enabled: true + scala-fork-join: + enabled: true + spark: + enabled: true + spring-batch: + enabled: true + spring-core: + enabled: true + spring-data: + enabled: true + spring-jms: + enabled: true + spring-integration: + enabled: true + spring-kafka: + enabled: true + spring-rabbit: + enabled: true + spring-rmi: + enabled: true + spring-scheduling: + enabled: true + spring-web: + enabled: true + spring-webflux: + enabled: true + spring-webmvc: + enabled: true + spring-ws: + enabled: true + spymemcached: + enabled: true + tomcat-jdbc: + enabled: true + twilio: + enabled: true + finatra: + enabled: true + undertow: + enabled: true + vaadin: + enabled: true + vibur-dbcp: + enabled: true + xxl-job: + enabled: true + zio: + enabled: true From f4bfd742d23d638670cf4f83814f500f9e8ba224 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Mon, 23 Sep 2024 12:57:52 -0500 Subject: [PATCH 02/10] Add additional properties, documentation --- javaagent/sdk-config.yaml | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/javaagent/sdk-config.yaml b/javaagent/sdk-config.yaml index 0c84e5e695..a6aa4571ad 100644 --- a/javaagent/sdk-config.yaml +++ b/javaagent/sdk-config.yaml @@ -39,12 +39,67 @@ meter_provider: aggregation: drop: +# Configure otel java agent instrumentation. A standard translation process 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: +# +# - Only properties starting with "otel.instrumentation." are resolved +# - 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 +# TODO: add automation to keep this in sync with system property / env var documentation: https://opentelemetry.io/docs/zero-code/java/agent/ instrumentation: java: common: default-enabled: true + db-statement-sanitizer: + enabled: true + enduser: + id: + enabled: false + role: + enabled: false + scope: + enabled: false + peer-service-mapping: {} + experimental: + controller-telemetry: + enabled: true + span-suppression-strategy: semconv + http: + client: + capture-request-headers: [] + capture-response-headers: [] + emit-experimental-telemetry: false + server: + capture-request-headers: [] + capture-response-headers: [] + emit-experimental-telemetry: false + known-methods: + - CONNECT + - DELETE + - GET + - HEAD + - OPTIONS + - PATCH + - POST + - PUT + - TRACE + messaging: + experimental: + receive-telemetry: + enabled: false methods: enabled: true + include: "" external-annotations: enabled: true akka-actor: @@ -175,6 +230,8 @@ instrumentation: enabled: false servlet: enabled: true + experimental: + capture-request-parameters: [] executors: enabled: true java-util-logging: @@ -231,6 +288,7 @@ instrumentation: enabled: true opentelemetry-instrumentation-annotations: enabled: true + exclude-methods: "" opentelemetry-api: enabled: true oracle-ucp: @@ -291,6 +349,12 @@ instrumentation: enabled: true spring-scheduling: enabled: true + spring-security: + enduser: + role: + granted-authority-prefix: ROLE_ + scope: + granted-authority-prefix: SCOPE_ spring-web: enabled: true spring-webflux: From e72a9587541a5538510f342d94ab1e4cf51c9bc0 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Fri, 18 Oct 2024 16:38:25 -0500 Subject: [PATCH 03/10] Rename sdk-migration-config.yaml, demonstrate config of single instrumentation rather than an exhaustive list --- javaagent/README.md | 2 +- javaagent/build.gradle.kts | 2 +- javaagent/docker-compose.yml | 10 +- javaagent/sdk-config.yaml | 383 ---------------------------- javaagent/sdk-migration-config.yaml | 272 ++++++++++++++++++++ 5 files changed, 280 insertions(+), 389 deletions(-) delete mode 100644 javaagent/sdk-config.yaml create mode 100644 javaagent/sdk-migration-config.yaml diff --git a/javaagent/README.md b/javaagent/README.md index 884acd53af..4a55b96688 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -52,7 +52,7 @@ By default, this example uses the [environment variable configuration schema](ht To use file 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 +export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-migration-config.yaml ``` Note that toggling file configuration causes the environment variable configuration scheme to be ignored completely. However, there is support for environment variable substitution within configuration files. diff --git a/javaagent/build.gradle.kts b/javaagent/build.gradle.kts index 42a4b68e9e..2454fa884a 100644 --- a/javaagent/build.gradle.kts +++ b/javaagent/build.gradle.kts @@ -25,7 +25,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.9.0") -:w} +} val copyAgent = tasks.register("copyAgent") { from(agent.singleFile) diff --git a/javaagent/docker-compose.yml b/javaagent/docker-compose.yml index 15605bbd08..8d60e71467 100644 --- a/javaagent/docker-compose.yml +++ b/javaagent/docker-compose.yml @@ -4,16 +4,18 @@ services: build: ./ environment: OTEL_SERVICE_NAME: "agent-example-app" - OTEL_EXPORTER_OTLP_ENDPOINT: "http://collector:4318" + 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: /sdk-config.yaml + # To use, call "export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-migration-config.yaml" before calling docker compose up + OTEL_EXPERIMENTAL_CONFIG_FILE: /sdk-migration-config.yaml ports: - "8080:8080" volumes: - - ./sdk-config.yaml:/sdk-config.yaml + - ./sdk-migration-config.yaml:/sdk-migration-config.yaml depends_on: - collector collector: diff --git a/javaagent/sdk-config.yaml b/javaagent/sdk-config.yaml deleted file mode 100644 index a6aa4571ad..0000000000 --- a/javaagent/sdk-config.yaml +++ /dev/null @@ -1,383 +0,0 @@ -file_format: "0.1" - -resource: - attributes: - - name: service.name - value: agent-example-app - -logger_provider: - processors: - - batch: - exporter: - otlp: - endpoint: http://collector:4318/v1/logs - protocol: http/protobuf - -tracer_provider: - processors: - - batch: - exporter: - otlp: - endpoint: http://collector:4318/v1/traces - protocol: http/protobuf - -meter_provider: - readers: - - periodic: - interval: 5000 - exporter: - otlp: - endpoint: http://collector:4318/v1/metrics - protocol: http/protobuf - # Example of how to use view to drop a metric which isn't needed. - # This configuration is not available with the environment variable configuration scheme. - # NOTE: most users will want jvm.memory.limit metric and should remove this view. - views: - - selector: - instrument_name: jvm.memory.limit - stream: - aggregation: - drop: - -# Configure otel java agent instrumentation. A standard translation process 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: -# -# - Only properties starting with "otel.instrumentation." are resolved -# - 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 -# TODO: add automation to keep this in sync with system property / env var documentation: https://opentelemetry.io/docs/zero-code/java/agent/ -instrumentation: - java: - common: - default-enabled: true - db-statement-sanitizer: - enabled: true - enduser: - id: - enabled: false - role: - enabled: false - scope: - enabled: false - peer-service-mapping: {} - experimental: - controller-telemetry: - enabled: true - span-suppression-strategy: semconv - http: - client: - capture-request-headers: [] - capture-response-headers: [] - emit-experimental-telemetry: false - server: - capture-request-headers: [] - capture-response-headers: [] - emit-experimental-telemetry: false - known-methods: - - CONNECT - - DELETE - - GET - - HEAD - - OPTIONS - - PATCH - - POST - - PUT - - TRACE - messaging: - experimental: - receive-telemetry: - enabled: false - methods: - enabled: true - include: "" - external-annotations: - enabled: true - akka-actor: - enabled: true - akka-http: - enabled: true - axis2: - enabled: true - camel: - enabled: true - cassandra: - enabled: true - cxf: - enabled: true - apache-dbcp: - enabled: true - apache-dubbo: - enabled: true - geode: - enabled: true - apache-httpasyncclient: - enabled: true - apache-httpclient: - enabled: true - kafka: - enabled: true - jsf-myfaces: - enabled: true - pekko-actor: - enabled: true - pekko-http: - enabled: true - pulsar: - enabled: true - rocketmq-client: - enabled: true - apache-shenyu: - enabled: true - struts: - enabled: true - tapestry: - enabled: true - tomcat: - enabled: true - wicket: - enabled: true - armeria: - enabled: true - async-http-client: - enabled: true - aws-lambda: - enabled: true - aws-sdk: - enabled: true - azure-core: - enabled: true - clickhouse: - enabled: true - couchbase: - enabled: true - c3p0: - enabled: true - dropwizard-views: - enabled: true - dropwizard-metrics: - enabled: true - grizzly: - enabled: true - jersey: - enabled: true - jetty: - enabled: true - jetty-httpclient: - enabled: true - metro: - enabled: true - jsf-mojarra: - enabled: true - vertx-http-client: - enabled: true - vertx-kafka-client: - enabled: true - vertx-redis-client: - enabled: true - vertx-rx-java: - enabled: true - vertx-sql-client: - enabled: true - vertx-web: - enabled: true - elasticsearch-transport: - enabled: true - elasticsearch-rest: - enabled: true - finagle-http: - enabled: true - guava: - enabled: true - google-http-client: - enabled: true - gwt: - enabled: true - grails: - enabled: true - graphql-java: - enabled: true - grpc: - enabled: true - hibernate: - enabled: true - hibernate-reactive: - enabled: true - hikaricp: - enabled: true - influxdb: - enabled: true - java-http-client: - enabled: true - http-url-connection: - enabled: true - jdbc: - enabled: true - jdbc-datasource: - enabled: true - rmi: - enabled: true - runtime-telemetry: - enabled: false - servlet: - enabled: true - experimental: - capture-request-parameters: [] - executors: - enabled: true - java-util-logging: - enabled: true - javalin: - enabled: true - jaxrs-client: - enabled: true - jaxrs: - enabled: true - jaxws: - enabled: true - jboss-logmanager-appender: - enabled: true - jboss-logmanager-mdc: - enabled: true - jms: - enabled: true - jodd-http: - enabled: true - jsp: - enabled: true - kubernetes-client: - enabled: true - ktor: - enabled: true - kotlinx-coroutines: - enabled: true - log4j-appender: - enabled: true - log4j-mdc: - enabled: true - log4j-context-data: - enabled: true - logback-appender: - enabled: true - logback-mdc: - enabled: true - micrometer: - enabled: true - mongo: - enabled: true - mybatis: - enabled: true - hystrix: - enabled: true - netty: - enabled: true - okhttp: - enabled: true - liberty: - enabled: true - opentelemetry-extension-annotations: - enabled: true - opentelemetry-instrumentation-annotations: - enabled: true - exclude-methods: "" - opentelemetry-api: - enabled: true - oracle-ucp: - enabled: true - oshi: - enabled: true - play: - enabled: true - play-ws: - enabled: true - quarkus: - enabled: true - quartz: - enabled: true - r2dbc: - enabled: true - rabbitmq: - enabled: true - ratpack: - enabled: true - rxjava: - enabled: true - reactor: - enabled: true - reactor-kafka: - enabled: true - reactor-netty: - enabled: true - jedis: - enabled: true - lettuce: - enabled: true - rediscala: - enabled: true - redisson: - enabled: true - restlet: - enabled: true - scala-fork-join: - enabled: true - spark: - enabled: true - spring-batch: - enabled: true - spring-core: - enabled: true - spring-data: - enabled: true - spring-jms: - enabled: true - spring-integration: - enabled: true - spring-kafka: - enabled: true - spring-rabbit: - enabled: true - spring-rmi: - enabled: true - spring-scheduling: - enabled: true - spring-security: - enduser: - role: - granted-authority-prefix: ROLE_ - scope: - granted-authority-prefix: SCOPE_ - spring-web: - enabled: true - spring-webflux: - enabled: true - spring-webmvc: - enabled: true - spring-ws: - enabled: true - spymemcached: - enabled: true - tomcat-jdbc: - enabled: true - twilio: - enabled: true - finatra: - enabled: true - undertow: - enabled: true - vaadin: - enabled: true - vibur-dbcp: - enabled: true - xxl-job: - enabled: true - zio: - enabled: true diff --git a/javaagent/sdk-migration-config.yaml b/javaagent/sdk-migration-config.yaml new file mode 100644 index 0000000000..7cf6bb61c1 --- /dev/null +++ b/javaagent/sdk-migration-config.yaml @@ -0,0 +1,272 @@ +# Copy of https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-migration-config.yaml +# with additional OpenTelemetry Java Agent properties added at .instrumentation.java. +# +# sdk-migration-config.yaml is a typical starting point for configuring the SDK when migrating +# from environment variable based configuration. +# +# This template includes env var substitution references (i.e. ${MY_ENV}) for all spec defined +# env vars (https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) +# which map cleanly to file configuration. For example, OTEL_SDK_DISABLED is referenced below, +# but OTEL_TRACES_EXPORTER is not since it does not map well to the hierarchical structure of +# file configuration. +# +# NOTE: With the exception of env var substitution syntax, SDKs ignore environment variables +# when interpreting config files. For example, if "disabled: ${OTEL_SDK_DISABLED:-false}" +# is replaced with "disabled: false", then setting the env var OTEL_SDK_DISABLED will have +# no effect. See https://opentelemetry.io/docs/specs/otel/configuration/file-configuration/ +# for more information. The following spec defined env vars are NOT referenced and are thus +# ignored: +# +# - OTEL_LOG_LEVEL +# - OTEL_PROPAGATORS +# - OTEL_TRACES_SAMPLER +# - OTEL_TRACES_SAMPLER_ARG +# - OTEL_EXPORTER_ZIPKIN_ENDPOINT +# - OTEL_EXPORTER_ZIPKIN_TIMEOUT +# - OTEL_EXPORTER_PROMETHEUS_HOST +# - OTEL_EXPORTER_PROMETHEUS_PORT +# - OTEL_TRACES_EXPORTER +# - OTEL_METRICS_EXPORTER +# - OTEL_LOGS_EXPORTER +# - OTEL_METRICS_EXEMPLAR_FILTER +# - OTEL_EXPORTER_OTLP_PROTOCOL +# - OTEL_EXPORTER_OTLP_ENDPOINT +# - OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_{SIGNAL}_INSECURE +# - OTEL_EXPORTER_OTLP_CERTIFICATE +# - OTEL_EXPORTER_OTLP_CLIENT_KEY +# - OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE +# - OTEL_EXPORTER_OTLP_COMPRESSION +# - OTEL_EXPORTER_OTLP_TIMEOUT + +# The file format version The file format version. +# TODO: the current support file format is 0.3, but the opentelemetry-java errantly checks that it is 0.1. This will be fixed in 1.44.0. +file_format: "0.1" + +# 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: ${OTEL_SDK_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: ${OTEL_SERVICE_NAME:-unknown_service} + # Configure resource attributes. Entries have lower priority than entries from .resource.attributes. + # The value is a list of comma separated key-value pairs matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. + attributes_list: ${OTEL_RESOURCE_ATTRIBUTES} + +# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. +attribute_limits: + # Configure max attribute value size. + attribute_value_length_limit: ${OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT} + # Configure max attribute count. + attribute_count_limit: ${OTEL_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: ${OTEL_BSP_SCHEDULE_DELAY:-5000} + # Configure maximum allowed time (in milliseconds) to export data. + export_timeout: ${OTEL_BSP_EXPORT_TIMEOUT:-30000} + # Configure maximum queue size. + max_queue_size: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048} + # Configure maximum batch size. + max_export_batch_size: ${OTEL_BSP_MAX_EXPORT_BATCH_SIZE:-512} + # Configure exporter. + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + protocol: ${OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:-http/protobuf} + # Configure endpoint. + endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces} + # Configure certificate. + certificate: ${OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE} + # Configure mTLS private client key. + client_key: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY} + # Configure mTLS client certificate. + client_certificate: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE} + # Configure compression. + compression: ${OTEL_EXPORTER_OTLP_TRACES_COMPRESSION:-gzip} + # Configure max time (in milliseconds) to wait for each export. + timeout: ${OTEL_EXPORTER_OTLP_TRACES_TIMEOUT:-10000} + # Configure headers. Entries have higher priority than entries from .headers_list. + headers: [] + # Configure headers. Entries have lower priority than entries from .headers. + # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. + headers_list: ${OTEL_EXPORTER_OTLP_TRACES_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: ${OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT} + # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. + attribute_count_limit: ${OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:-128} + # Configure max span event count. + event_count_limit: ${OTEL_SPAN_EVENT_COUNT_LIMIT:-128} + # Configure max span link count. + link_count_limit: ${OTEL_SPAN_LINK_COUNT_LIMIT:-128} + # Configure max attributes per span event. + event_attribute_count_limit: ${OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT:-128} + # Configure max attributes per span link. + link_attribute_count_limit: ${OTEL_LINK_ATTRIBUTE_COUNT_LIMIT:-128} + # Configure the sampler. + sampler: + # Configure sampler to be parent_based. + parent_based: + # Configure root sampler. + root: + # Configure sampler to be always_on. + always_on: {} + # 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: ${OTEL_METRIC_EXPORT_INTERVAL:-60000} + # Configure maximum allowed time (in milliseconds) to export data. + timeout: ${OTEL_METRIC_EXPORT_TIMEOUT:-30000} + # Configure exporter. + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + protocol: ${OTEL_EXPORTER_OTLP_METRICS_PROTOCOL:-http/protobuf} + # Configure endpoint. + endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics} + # Configure certificate. + certificate: ${OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE} + # Configure mTLS private client key. + client_key: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY} + # Configure mTLS client certificate. + client_certificate: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE} + # Configure compression. + compression: ${OTEL_EXPORTER_OTLP_METRICS_COMPRESSION:-gzip} + # Configure max time (in milliseconds) to wait for each export. + timeout: ${OTEL_EXPORTER_OTLP_METRICS_TIMEOUT:-10000} + # Configure headers. Entries have higher priority than entries from .headers_list. + headers: [] + # Configure headers. Entries have lower priority than entries from .headers. + # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. + headers_list: ${OTEL_EXPORTER_OTLP_METRICS_HEADERS} + # Configure temporality preference. + temporality_preference: ${OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:-cumulative} + # Configure default histogram aggregation. + default_histogram_aggregation: ${OTEL_EXPORTER_OTLP_METRICS_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: ${OTEL_BLRP_SCHEDULE_DELAY:-1000} + # Configure maximum allowed time (in milliseconds) to export data. + export_timeout: ${OTEL_BLRP_EXPORT_TIMEOUT:-30000} + # Configure maximum queue size. + max_queue_size: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048} + # Configure maximum batch size. + max_export_batch_size: ${OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:-512} + # Configure exporter. + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + protocol: ${OTEL_EXPORTER_OTLP_LOGS_PROTOCOL:-http/protobuf} + # Configure endpoint. + endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs} + # Configure certificate. + certificate: ${OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE} + # Configure mTLS private client key. + client_key: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY} + # Configure mTLS client certificate. + client_certificate: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE} + # Configure compression. + compression: ${OTEL_EXPORTER_OTLP_LOGS_COMPRESSION:-gzip} + # Configure max time (in milliseconds) to wait for each export. + timeout: ${OTEL_EXPORTER_OTLP_LOGS_TIMEOUT:-10000} + # Configure headers. Entries have higher priority than entries from .headers_list. + headers: [] + # Configure headers. Entries have lower priority than entries from .headers. + # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. + headers_list: ${OTEL_EXPORTER_OTLP_LOGS_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: ${OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT} + # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. + attribute_count_limit: ${OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:-128} + +# Configure instrumentation. +instrumentation: + # Configure OpenTelemetry Java Agent. A standard translation process 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: ${OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED:-true} + java-util-logging: + enabled: ${OTEL_INSTRUMENTATION_JAVA_UTIL_LOGGING_ENABLED:-true} + # 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: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_ENABLED:-true} + experimental-log-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_LOG_ATTRIBUTES:-false} + experimental: + capture-code-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_CODE_ATTRIBUTES:-false} + capture-marker-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_MARKER_ATTRIBUTE:-false} + capture-key-value-pair-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_KEY_VALUE_PAIR_ATTRIBUTES:-false} + capture-logger-context-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_LOGGER_CONTEXT_ATTRIBUTES:-false} + capture-arguments: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_ARGUMENTS:-false} + capture-mdc-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_MDC_ATTRIBUTES} From 136a4d802d084f1e77806de3cfaea1d26aae4e32 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Fri, 18 Oct 2024 17:07:11 -0500 Subject: [PATCH 04/10] Add extension with rule based routing sampler --- javaagent/Dockerfile | 3 ++- javaagent/README.md | 7 +++++-- javaagent/build.gradle.kts | 13 +++++++++++++ javaagent/sdk-migration-config.yaml | 21 ++++++++++++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/javaagent/Dockerfile b/javaagent/Dockerfile index 98dd8d66e1..2f4f08a7b5 100644 --- a/javaagent/Dockerfile +++ b/javaagent/Dockerfile @@ -2,5 +2,6 @@ FROM eclipse-temurin:11-jre ADD build/libs/app.jar /app.jar ADD build/agent/opentelemetry-javaagent.jar /opentelemetry-javaagent.jar +ADD build/agent/opentelemetry-javaagent-extension.jar /opentelemetry-javaagent-extension.jar -ENTRYPOINT java -jar -javaagent:/opentelemetry-javaagent.jar /app.jar +ENTRYPOINT java -jar -javaagent:/opentelemetry-javaagent.jar -Dotel.javaagent.extensions=/opentelemetry-javaagent-extension.jar /app.jar diff --git a/javaagent/README.md b/javaagent/README.md index 4a55b96688..170fa16fbd 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -47,7 +47,10 @@ Watch for spans, metrics, and logs in the collector log output ## File 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 file configuration scheme can be used instead. `sdk-config.yaml` demonstrates view configuration to disable a metric, something which is not available in the environment variable configuration scheme. +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-migration-config.yaml](./sdk-migration-config.yaml) which demonstrates how the file configuration scheme can be used instead. `sdk-migration-config.yaml` extends the [opentelemetry-configuration sdk-migration-config.yaml](https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-migration-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`) To use file configuration instead of the environment variable scheme, add the following before starting the application and collector: @@ -55,4 +58,4 @@ To use file configuration instead of the environment variable scheme, add the fo export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-migration-config.yaml ``` -Note that toggling file configuration causes the environment variable configuration scheme to be ignored completely. However, there is support for environment variable substitution within configuration files. +Note besides the environment variables referenced in `sdk-migration-config.yaml` using [substitution syntax](https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution), environment variables are ignored. diff --git a/javaagent/build.gradle.kts b/javaagent/build.gradle.kts index 2454fa884a..810edbb627 100644 --- a/javaagent/build.gradle.kts +++ b/javaagent/build.gradle.kts @@ -16,6 +16,7 @@ java { } val agent = configurations.create("agent") +val extension = configurations.create("extension") dependencies { implementation(platform(SpringBootPlugin.BOM_COORDINATES)) @@ -23,8 +24,10 @@ dependencies { //spring modules implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-actuator") agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.9.0") + extension("io.opentelemetry.contrib:opentelemetry-samplers:1.40.0-alpha") } val copyAgent = tasks.register("copyAgent") { @@ -33,9 +36,19 @@ val copyAgent = tasks.register("copyAgent") { rename("opentelemetry-javaagent-.*\\.jar", "opentelemetry-javaagent.jar") } +val copyExtension = tasks.register("copyExtension") { + from(extension.files) { + include("opentelemetry-samplers-*.jar") + exclude("*sources.jar") + exclude("*javadoc.jar") + } + into(layout.buildDirectory.dir("agent")) + rename(".*\\.jar", "opentelemetry-javaagent-extension.jar") +} tasks.named("bootJar") { dependsOn(copyAgent) + dependsOn(copyExtension) archiveFileName = "app.jar" } diff --git a/javaagent/sdk-migration-config.yaml b/javaagent/sdk-migration-config.yaml index 7cf6bb61c1..a13f4fab56 100644 --- a/javaagent/sdk-migration-config.yaml +++ b/javaagent/sdk-migration-config.yaml @@ -13,7 +13,7 @@ # NOTE: With the exception of env var substitution syntax, SDKs ignore environment variables # when interpreting config files. For example, if "disabled: ${OTEL_SDK_DISABLED:-false}" # is replaced with "disabled: false", then setting the env var OTEL_SDK_DISABLED will have -# no effect. See https://opentelemetry.io/docs/specs/otel/configuration/file-configuration/ +# no effect. See https://opentelemetry.io/docs/specs/otel/configuration/data-model/#file-based-configuration-model # for more information. The following spec defined env vars are NOT referenced and are thus # ignored: # @@ -143,6 +143,22 @@ tracer_provider: local_parent_not_sampled: # Configure sampler to be always_off. always_off: {} + # Uncomment to configure the rule_based_routing sampler from https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/samplers + # to drop spans to spring actuator endpoints. + # Configure the parent_based sampler's root sampler to be rule_based_routing sampler. + # 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 meter provider. meter_provider: @@ -256,8 +272,11 @@ instrumentation: java: common: default-enabled: ${OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED:-true} + # Configuration logback-appender instrumentation. Properties adapted from: + # https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/java-util-logging/javaagent java-util-logging: enabled: ${OTEL_INSTRUMENTATION_JAVA_UTIL_LOGGING_ENABLED:-true} + experimental-log-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_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: From 44d2c60732b79d084ff0712ae5ab6b03fec8c2f2 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Fri, 18 Oct 2024 17:13:05 -0500 Subject: [PATCH 05/10] Revert mavenLocal --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 188394996c..cdc9cdab95 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,6 @@ subprojects { version = "0.1.0-SNAPSHOT" repositories { - mavenLocal() mavenCentral() } From 12645a7a335d97ea3c0e77cc2be189ee6420f4fc Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Fri, 18 Oct 2024 17:20:59 -0500 Subject: [PATCH 06/10] entrypoint arg order --- javaagent/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaagent/Dockerfile b/javaagent/Dockerfile index 2f4f08a7b5..3a5d7870c2 100644 --- a/javaagent/Dockerfile +++ b/javaagent/Dockerfile @@ -4,4 +4,4 @@ ADD build/libs/app.jar /app.jar ADD build/agent/opentelemetry-javaagent.jar /opentelemetry-javaagent.jar ADD build/agent/opentelemetry-javaagent-extension.jar /opentelemetry-javaagent-extension.jar -ENTRYPOINT java -jar -javaagent:/opentelemetry-javaagent.jar -Dotel.javaagent.extensions=/opentelemetry-javaagent-extension.jar /app.jar +ENTRYPOINT java -javaagent:/opentelemetry-javaagent.jar -Dotel.javaagent.extensions=/opentelemetry-javaagent-extension.jar -jar /app.jar From f9f0037a29e77636677b7b52b71f6becde5b12bc Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Mon, 21 Oct 2024 13:03:47 -0500 Subject: [PATCH 07/10] Improve copyExtension gradle task --- javaagent/build.gradle.kts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/javaagent/build.gradle.kts b/javaagent/build.gradle.kts index 810edbb627..9252c7200c 100644 --- a/javaagent/build.gradle.kts +++ b/javaagent/build.gradle.kts @@ -27,7 +27,9 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-actuator") agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.9.0") - extension("io.opentelemetry.contrib:opentelemetry-samplers:1.40.0-alpha") + extension("io.opentelemetry.contrib:opentelemetry-samplers:1.40.0-alpha") { + isTransitive = false + } } val copyAgent = tasks.register("copyAgent") { @@ -37,11 +39,7 @@ val copyAgent = tasks.register("copyAgent") { } val copyExtension = tasks.register("copyExtension") { - from(extension.files) { - include("opentelemetry-samplers-*.jar") - exclude("*sources.jar") - exclude("*javadoc.jar") - } + from(extension.singleFile) into(layout.buildDirectory.dir("agent")) rename(".*\\.jar", "opentelemetry-javaagent-extension.jar") } From cde4737ba88ecdba4978649ed849699cc25523bf Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Mon, 21 Oct 2024 13:06:54 -0500 Subject: [PATCH 08/10] Fix typo --- javaagent/sdk-migration-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaagent/sdk-migration-config.yaml b/javaagent/sdk-migration-config.yaml index a13f4fab56..dd4b7fa7db 100644 --- a/javaagent/sdk-migration-config.yaml +++ b/javaagent/sdk-migration-config.yaml @@ -244,7 +244,7 @@ logger_provider: # Configure instrumentation. instrumentation: - # Configure OpenTelemetry Java Agent. A standard translation process applied to convert the + # 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: # From cb4f539465d4bd4ad6ce1fc98500d0428c6132a0 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Mon, 21 Oct 2024 14:06:34 -0500 Subject: [PATCH 09/10] Use sdk-config.yaml, default to rule_based_routing sampler --- javaagent/README.md | 8 +- javaagent/docker-compose.yml | 6 +- javaagent/sdk-config.yaml | 247 +++++++++++++++++++++++ javaagent/sdk-migration-config.yaml | 291 ---------------------------- 4 files changed, 254 insertions(+), 298 deletions(-) create mode 100644 javaagent/sdk-config.yaml delete mode 100644 javaagent/sdk-migration-config.yaml diff --git a/javaagent/README.md b/javaagent/README.md index 170fa16fbd..c6cf71fe5a 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -47,15 +47,15 @@ Watch for spans, metrics, and logs in the collector log output ## File 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-migration-config.yaml](./sdk-migration-config.yaml) which demonstrates how the file configuration scheme can be used instead. `sdk-migration-config.yaml` extends the [opentelemetry-configuration sdk-migration-config.yaml](https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-migration-config.yaml) template, demonstrating: +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-migration-config.yaml](./sdk-migration-config.yaml) which demonstrates how the file configuration scheme can be used instead. `sdk-migration-config.yaml` extends the [opentelemetry-configuration sdk-migration-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`) +- 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 file configuration instead of the environment variable scheme, add the following before starting the application and collector: ```shell -export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-migration-config.yaml +export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml ``` -Note besides the environment variables referenced in `sdk-migration-config.yaml` using [substitution syntax](https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution), environment variables are ignored. +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 8d60e71467..4f3968d7ab 100644 --- a/javaagent/docker-compose.yml +++ b/javaagent/docker-compose.yml @@ -10,12 +10,12 @@ services: # 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-migration-config.yaml" before calling docker compose up - OTEL_EXPERIMENTAL_CONFIG_FILE: /sdk-migration-config.yaml + # To use, call "export OTEL_EXPERIMENTAL_CONFIG_FILE=/sdk-config.yaml" before calling docker compose up + OTEL_EXPERIMENTAL_CONFIG_FILE: ports: - "8080:8080" volumes: - - ./sdk-migration-config.yaml:/sdk-migration-config.yaml + - ./sdk-config.yaml:/sdk-config.yaml depends_on: - collector collector: diff --git a/javaagent/sdk-config.yaml b/javaagent/sdk-config.yaml new file mode 100644 index 0000000000..143e725e6c --- /dev/null +++ b/javaagent/sdk-config.yaml @@ -0,0 +1,247 @@ +# Copy of https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/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. +# TODO: the current support file format is 0.3, but the opentelemetry-java errantly checks that it is 0.1. This will be fixed in 1.44.0. +file_format: "0.1" + +# 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 logback-appender 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/javaagent/sdk-migration-config.yaml b/javaagent/sdk-migration-config.yaml deleted file mode 100644 index dd4b7fa7db..0000000000 --- a/javaagent/sdk-migration-config.yaml +++ /dev/null @@ -1,291 +0,0 @@ -# Copy of https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-migration-config.yaml -# with additional OpenTelemetry Java Agent properties added at .instrumentation.java. -# -# sdk-migration-config.yaml is a typical starting point for configuring the SDK when migrating -# from environment variable based configuration. -# -# This template includes env var substitution references (i.e. ${MY_ENV}) for all spec defined -# env vars (https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) -# which map cleanly to file configuration. For example, OTEL_SDK_DISABLED is referenced below, -# but OTEL_TRACES_EXPORTER is not since it does not map well to the hierarchical structure of -# file configuration. -# -# NOTE: With the exception of env var substitution syntax, SDKs ignore environment variables -# when interpreting config files. For example, if "disabled: ${OTEL_SDK_DISABLED:-false}" -# is replaced with "disabled: false", then setting the env var OTEL_SDK_DISABLED will have -# no effect. See https://opentelemetry.io/docs/specs/otel/configuration/data-model/#file-based-configuration-model -# for more information. The following spec defined env vars are NOT referenced and are thus -# ignored: -# -# - OTEL_LOG_LEVEL -# - OTEL_PROPAGATORS -# - OTEL_TRACES_SAMPLER -# - OTEL_TRACES_SAMPLER_ARG -# - OTEL_EXPORTER_ZIPKIN_ENDPOINT -# - OTEL_EXPORTER_ZIPKIN_TIMEOUT -# - OTEL_EXPORTER_PROMETHEUS_HOST -# - OTEL_EXPORTER_PROMETHEUS_PORT -# - OTEL_TRACES_EXPORTER -# - OTEL_METRICS_EXPORTER -# - OTEL_LOGS_EXPORTER -# - OTEL_METRICS_EXEMPLAR_FILTER -# - OTEL_EXPORTER_OTLP_PROTOCOL -# - OTEL_EXPORTER_OTLP_ENDPOINT -# - OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_{SIGNAL}_INSECURE -# - OTEL_EXPORTER_OTLP_CERTIFICATE -# - OTEL_EXPORTER_OTLP_CLIENT_KEY -# - OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE -# - OTEL_EXPORTER_OTLP_COMPRESSION -# - OTEL_EXPORTER_OTLP_TIMEOUT - -# The file format version The file format version. -# TODO: the current support file format is 0.3, but the opentelemetry-java errantly checks that it is 0.1. This will be fixed in 1.44.0. -file_format: "0.1" - -# 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: ${OTEL_SDK_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: ${OTEL_SERVICE_NAME:-unknown_service} - # Configure resource attributes. Entries have lower priority than entries from .resource.attributes. - # The value is a list of comma separated key-value pairs matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. - attributes_list: ${OTEL_RESOURCE_ATTRIBUTES} - -# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. -attribute_limits: - # Configure max attribute value size. - attribute_value_length_limit: ${OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. - attribute_count_limit: ${OTEL_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: ${OTEL_BSP_SCHEDULE_DELAY:-5000} - # Configure maximum allowed time (in milliseconds) to export data. - export_timeout: ${OTEL_BSP_EXPORT_TIMEOUT:-30000} - # Configure maximum queue size. - max_queue_size: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048} - # Configure maximum batch size. - max_export_batch_size: ${OTEL_BSP_MAX_EXPORT_BATCH_SIZE:-512} - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: ${OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:-http/protobuf} - # Configure endpoint. - endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces} - # Configure certificate. - certificate: ${OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE} - # Configure mTLS private client key. - client_key: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY} - # Configure mTLS client certificate. - client_certificate: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE} - # Configure compression. - compression: ${OTEL_EXPORTER_OTLP_TRACES_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - timeout: ${OTEL_EXPORTER_OTLP_TRACES_TIMEOUT:-10000} - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - headers_list: ${OTEL_EXPORTER_OTLP_TRACES_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: ${OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - attribute_count_limit: ${OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure max span event count. - event_count_limit: ${OTEL_SPAN_EVENT_COUNT_LIMIT:-128} - # Configure max span link count. - link_count_limit: ${OTEL_SPAN_LINK_COUNT_LIMIT:-128} - # Configure max attributes per span event. - event_attribute_count_limit: ${OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure max attributes per span link. - link_attribute_count_limit: ${OTEL_LINK_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure the sampler. - sampler: - # Configure sampler to be parent_based. - parent_based: - # Configure root sampler. - root: - # Configure sampler to be always_on. - always_on: {} - # 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: {} - # Uncomment to configure the rule_based_routing sampler from https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/samplers - # to drop spans to spring actuator endpoints. - # Configure the parent_based sampler's root sampler to be rule_based_routing sampler. - # 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 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: ${OTEL_METRIC_EXPORT_INTERVAL:-60000} - # Configure maximum allowed time (in milliseconds) to export data. - timeout: ${OTEL_METRIC_EXPORT_TIMEOUT:-30000} - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: ${OTEL_EXPORTER_OTLP_METRICS_PROTOCOL:-http/protobuf} - # Configure endpoint. - endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics} - # Configure certificate. - certificate: ${OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE} - # Configure mTLS private client key. - client_key: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY} - # Configure mTLS client certificate. - client_certificate: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE} - # Configure compression. - compression: ${OTEL_EXPORTER_OTLP_METRICS_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - timeout: ${OTEL_EXPORTER_OTLP_METRICS_TIMEOUT:-10000} - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - headers_list: ${OTEL_EXPORTER_OTLP_METRICS_HEADERS} - # Configure temporality preference. - temporality_preference: ${OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:-cumulative} - # Configure default histogram aggregation. - default_histogram_aggregation: ${OTEL_EXPORTER_OTLP_METRICS_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: ${OTEL_BLRP_SCHEDULE_DELAY:-1000} - # Configure maximum allowed time (in milliseconds) to export data. - export_timeout: ${OTEL_BLRP_EXPORT_TIMEOUT:-30000} - # Configure maximum queue size. - max_queue_size: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048} - # Configure maximum batch size. - max_export_batch_size: ${OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:-512} - # Configure exporter. - exporter: - # Configure exporter to be OTLP. - otlp: - # Configure protocol. - protocol: ${OTEL_EXPORTER_OTLP_LOGS_PROTOCOL:-http/protobuf} - # Configure endpoint. - endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs} - # Configure certificate. - certificate: ${OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE} - # Configure mTLS private client key. - client_key: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY} - # Configure mTLS client certificate. - client_certificate: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE} - # Configure compression. - compression: ${OTEL_EXPORTER_OTLP_LOGS_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - timeout: ${OTEL_EXPORTER_OTLP_LOGS_TIMEOUT:-10000} - # Configure headers. Entries have higher priority than entries from .headers_list. - headers: [] - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - headers_list: ${OTEL_EXPORTER_OTLP_LOGS_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: ${OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - attribute_count_limit: ${OTEL_LOGRECORD_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: ${OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED:-true} - # Configuration logback-appender instrumentation. Properties adapted from: - # https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/java-util-logging/javaagent - java-util-logging: - enabled: ${OTEL_INSTRUMENTATION_JAVA_UTIL_LOGGING_ENABLED:-true} - experimental-log-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_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: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_ENABLED:-true} - experimental-log-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_LOG_ATTRIBUTES:-false} - experimental: - capture-code-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_CODE_ATTRIBUTES:-false} - capture-marker-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_MARKER_ATTRIBUTE:-false} - capture-key-value-pair-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_KEY_VALUE_PAIR_ATTRIBUTES:-false} - capture-logger-context-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_LOGGER_CONTEXT_ATTRIBUTES:-false} - capture-arguments: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_ARGUMENTS:-false} - capture-mdc-attributes: ${OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_MDC_ATTRIBUTES} From 9ff36671a6d68119a2cc451c6704653280d30522 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Mon, 21 Oct 2024 14:14:25 -0500 Subject: [PATCH 10/10] fix broken link --- javaagent/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaagent/README.md b/javaagent/README.md index c6cf71fe5a..cb994c2c9f 100644 --- a/javaagent/README.md +++ b/javaagent/README.md @@ -47,7 +47,7 @@ Watch for spans, metrics, and logs in the collector log output ## File 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-migration-config.yaml](./sdk-migration-config.yaml) which demonstrates how the file configuration scheme can be used instead. `sdk-migration-config.yaml` extends the [opentelemetry-configuration sdk-migration-config.yaml](https://github.com/open-telemetry/opentelemetry-configuration/blob/v0.3.0/examples/sdk-config.yaml) template, demonstrating: +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 file configuration scheme can be used 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`)