File tree Expand file tree Collapse file tree 6 files changed +26
-7
lines changed
java/io/opentelemetry/example/graal Expand file tree Collapse file tree 6 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ The example uses the following elements:
1111 the [ OTLP receiver] ( https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver )
1212 and exporting to the standard output with
1313 the [ logging exporter] ( https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/loggingexporter ) .
14+ - A spring configuration to suppress spans for the ` /actuator ` endpoint
1415
1516# Description of the instrumentation set-up
1617
@@ -147,4 +148,4 @@ spring-native-collector-1 | -> db.name: Str(db)
147148spring-native-collector-1 | -> db.connection_string: Str(h2:mem:)
148149spring-native-collector-1 | -> db.statement: Str(create table test_table (id bigint not null, primary key (id)))
149150spring-native-collector-1 | -> db.system: Str(h2)
150- ```
151+ ```
Original file line number Diff line number Diff line change @@ -13,8 +13,12 @@ dependencies {
1313 implementation(platform(SpringBootPlugin .BOM_COORDINATES ))
1414 implementation(platform(" io.opentelemetry:opentelemetry-bom:1.36.0" ))
1515 implementation(platform(" io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.2.0-alpha" ))
16+ implementation(" org.springframework.boot:spring-boot-starter-actuator" )
1617 implementation(" org.springframework.boot:spring-boot-starter-web" )
1718 implementation(" org.springframework.boot:spring-boot-starter-data-jdbc" )
1819 implementation(" com.h2database:h2" )
1920 implementation(" io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter" )
21+
22+ // for otelCustomizer in Application.java
23+ implementation(" io.opentelemetry.contrib:opentelemetry-samplers:1.33.0-alpha" )
2024}
Original file line number Diff line number Diff line change 11receivers :
22 otlp :
33 protocols :
4- grpc :
4+ http :
55exporters :
66 logging :
77 verbosity : detailed
Original file line number Diff line number Diff line change 1- version : ' 3'
1+ version : ' 3.8 '
22services :
33 app :
44 image : otel-native-graalvm
55 environment :
66 OTEL_SERVICE_NAME : " graal-native-example-app"
7- OTEL_EXPORTER_OTLP_ENDPOINT : " http://collector:4317"
8- # Logs are disabled by default
9- OTEL_LOGS_EXPORTER : " otlp"
7+ OTEL_EXPORTER_OTLP_ENDPOINT : " http://collector:4318"
108 ports :
119 - " 8080:8080"
1210 depends_on :
Original file line number Diff line number Diff line change 11package io .opentelemetry .example .graal ;
22
3+ import io .opentelemetry .api .trace .SpanKind ;
4+ import io .opentelemetry .contrib .sampler .RuleBasedRoutingSampler ;
5+ import io .opentelemetry .sdk .autoconfigure .spi .AutoConfigurationCustomizerProvider ;
6+ import io .opentelemetry .semconv .SemanticAttributes ;
37import org .springframework .boot .SpringApplication ;
48import org .springframework .boot .autoconfigure .SpringBootApplication ;
9+ import org .springframework .context .annotation .Bean ;
510
611@ SpringBootApplication
712public class Application {
813
914 public static void main (String [] args ) {
1015 SpringApplication .run (Application .class , args );
1116 }
17+
18+ @ Bean
19+ public AutoConfigurationCustomizerProvider otelCustomizer () {
20+ return p ->
21+ p .addSamplerCustomizer (
22+ (fallback , c ) ->
23+ RuleBasedRoutingSampler .builder (SpanKind .SERVER , fallback )
24+ .drop (SemanticAttributes .URL_PATH , "^/actuator" )
25+ .build ());
26+ }
1227}
Original file line number Diff line number Diff line change 11spring.datasource.url =jdbc:otel:h2:mem:db
2- spring.datasource.driver-class-name =io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
2+ spring.datasource.driver-class-name =io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
3+ management.endpoints.web.exposure.include =*
You can’t perform that action at this time.
0 commit comments