October 21, 2024
Chicago 12, Melborne City, USA
java

Setup SpringBoot Opentelemetry, exporter by zipkin, instrument with jdbc get Error


I want to

  • add traceId automatically in log (with MDC)
  • add spanId automatically when call redis or jdbc (I want to use opentelemetry instrumentation)
  • exporter to zipkin

my pom file

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.3.0</version>
    <relativePath/>
  </parent>

  </dependencies>
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>

    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-tracing-bridge-otel</artifactId>
    </dependency>

    <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-exporter-zipkin</artifactId>
    </dependency>

    <dependency>
      <groupId>io.opentelemetry.instrumentation</groupId>
      <artifactId>opentelemetry-spring-boot-starter</artifactId>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.opentelemetry.instrumentation</groupId>
        <artifactId>opentelemetry-instrumentation-bom</artifactId>
        <version>2.8.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  • It work without opentelemetry-spring-boot-starter, I can add traceId in log and export to zipkin, with application.yaml
management:
  zipkin:
    tracing:
      endpoint: http://localhost:9411/api/v2/spans
  • After add opentelemetry-exporter-zipkin, I got error
- Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: 
- Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0: 
- Error creating bean with name 'getDataSource' defined in class path resource [zalopay/pe/zaskeeper/infra/database/jdbc/config/JdbcConfig.class]: 
- Error creating bean with name 'openTelemetry' defined in class path resource [io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration$OpenTelemetrySdkConfig.class]: 
- Unsatisfied dependency expressed through method 'openTelemetry' parameter 0: 
- Error creating bean with name 'autoConfiguredOpenTelemetrySdk' defined in class path resource [io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration$OpenTelemetrySdkConfig.class]: 
- Failed to instantiate [io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk]: 
- Factory method 'autoConfiguredOpenTelemetrySdk' threw exception with message: io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider: 
- Provider io.opentelemetry.instrumentation.resources.ManifestResourceProvider could not be instantiated

I have tried to excluse some dependencies between libraries above, but it didn’t work.

Can anyone help me resolve this error, or guide me toward a new approach?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video