Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ To build the all of examples, run:
OpenTelemetry SDK to use a Zipkin exporter and send spans to a
Zipkin backend using the OpenTelemetry API.
- Note: This example requires Docker to be installed.
- [Declarative Configuration with the OpenTelemetry Java Agent](javaagent-declarative-configuration)
- This module demonstrates how to use declarative configuration with the
OpenTelemetry Java Agent to configure tracing behavior, including
excluding specific endpoints from tracing.
- Note: This example requires Java 17 or higher.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion javaagent-declarative-configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This Spring Boot application includes two endpoints:
## End-to-End Instructions

### Prerequisites
* Java 17 or higher
* Java 17 or higher (due to Spring Boot 3 requirement, not because of declarative config support)
* OpenTelemetry Java Agent JAR file (see next step)

Download the OpenTelemetry Java Agent:
Expand Down
6 changes: 6 additions & 0 deletions javaagent-declarative-configuration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ plugins {
description = "OpenTelemetry Java Agent Declarative Configuration Example"
val moduleName by extra { "io.opentelemetry.examples.javaagent.declarative" }

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

dependencies {
implementation(platform(SpringBootPlugin.BOM_COORDINATES))
implementation("org.springframework.boot:spring-boot-starter-web")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ services:
environment:
OTEL_SERVICE_NAME: "declarative-config-example-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"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 10s
timeout: 5s
retries: 3
retries: 3
21 changes: 17 additions & 4 deletions javaagent-declarative-configuration/otel-agent-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
# See https://github.com/open-telemetry/opentelemetry-configuration for details on schema and examples
# For schema documentation, including required properties, semantics, default behavior, etc,
# see: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md

file_format: "1.0-rc.2"

resource:
attributes:
- name: service.name
value: spring-boot-declarative-config-example
# Read resource attributes from the OTEL_RESOURCE_ATTRIBUTES environment variable.
# This aligns well with the OpenTelemetry Operator and other deployment methods.
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES}
detection/development: # /development properties may not be supported in all SDKs
detectors:
- service: # will add "service.instance.id" and "service.name" from the OTEL_SERVICE_NAME env var
- host:
- process:
- container:

propagator:
composite:
- tracecontext:
- baggage:

# Read backend endpoint from the OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
# This aligns well with the OpenTelemetry Operator and other deployment methods.

tracer_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces}
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces

# Configure a console exporter for exploring without a collector/backend
- batch:
Expand Down Expand Up @@ -45,11 +58,11 @@ meter_provider:
- periodic:
exporter:
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics}
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/metrics

logger_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs}
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/logs