Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demosntrate declarative config 0.3 with otel java agent #492

Merged
merged 11 commits into from
Oct 21, 2024
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ subprojects {
version = "0.1.0-SNAPSHOT"

repositories {
mavenLocal()
mavenCentral()
}

Expand Down
2 changes: 1 addition & 1 deletion javaagent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
jack-berg marked this conversation as resolved.
Show resolved Hide resolved
}

val copyAgent = tasks.register<Copy>("copyAgent") {
Expand Down
4 changes: 2 additions & 2 deletions javaagent/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
289 changes: 285 additions & 4 deletions javaagent/sdk-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@ 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:
processors:
- 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.
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

This instrumentation is not enbabled by default....do we want it enabled here? This also applies to:

  • jdbc-datasource
  • micrometer
  • mybatis
  • spring-batch

Copy link
Member

Choose a reason for hiding this comment

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

it should reflect the default values I think

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a change of heart on this. I realized that it would be near a huge effort to go and enumerate all the config options for all the instrumentation, especially since many are buried in the code without documentation. It would also be fragile, causing the config to break when breaking changes happen to the config, eroding user confidence.

Instead, I opted to give a thorough explanation of the mapping rules from system properties to declarative config YAML, and demonstrate the configuration of just a couple of modules as an example, leaving the user to apply the rules to configure additional instrumentation modules.

I also opted to base the sample config file on sdk-migration-config.yaml, which is much more exhaustive and includes helpful explanatory comments.

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
Loading