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

Spring boot 3.0.5 application not exporting logs to otel-collector #34921

Closed
ff-sdesai opened this issue Apr 10, 2023 · 1 comment
Closed

Spring boot 3.0.5 application not exporting logs to otel-collector #34921

ff-sdesai opened this issue Apr 10, 2023 · 1 comment
Labels
status: duplicate A duplicate of another issue theme: observability Issues related to observability

Comments

@ff-sdesai
Copy link

ff-sdesai commented Apr 10, 2023

I had created a Spring-boot micro-service using spring-cloud-sleuth for distributed-tracing. I had a otel-collector which was receiving logs and traces from the application and it was exporting it to Datadog. The flow was working properly.

However, starting from Spring-boot 3.0.5, support of sleuth is removed and observability has been split into two parts some in Spring-boot itself and some part in micrometer. I upgraded my spring-boot version and made changes to export traces to otel-collector . But the application is not exporting the traces to otel-collector. However, if I simply add the maven dependency for Zipkin, the application tries to export traces to Zipkin and shows error since Zipkin is not running at default expected address.

I enabled the Spring debug logs and I can see that the bean for OpenTelemetryAutoConfiguration is being created. In fact, I can see all the beans defined in this class are created. I have created a small reproducer with a very few files and can be found out here. I am posting the debug logs related to this class from the application:-


OpenTelemetryAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'io.micrometer.tracing.otel.bridge.OtelTracer', 'io.opentelemetry.sdk.trace.SdkTracerProvider', 'io.opentelemetry.api.OpenTelemetry' (OnClassCondition)
      - @ConditionalOnProperty (management.tracing.enabled) matched (OnPropertyCondition)

   OpenTelemetryAutoConfiguration#micrometerOtelTracer matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.Tracer; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#openTelemetry matched:
      - @ConditionalOnMissingBean (types: io.opentelemetry.api.OpenTelemetry; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelContextPropagators matched:
      - @ConditionalOnMissingBean (types: io.opentelemetry.context.propagation.ContextPropagators; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelCurrentTraceContext matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.otel.bridge.OtelCurrentTraceContext; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelPropagator matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.otel.bridge.OtelPropagator; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelSampler matched:
      - @ConditionalOnMissingBean (types: io.opentelemetry.sdk.trace.samplers.Sampler; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelSdkTracerProvider matched:
      - @ConditionalOnMissingBean (types: io.opentelemetry.sdk.trace.SdkTracerProvider; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelSlf4JEventListener matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.otel.bridge.Slf4JEventListener; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelSpanCustomizer matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.SpanCustomizer; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelTracer matched:
      - @ConditionalOnMissingBean (types: io.opentelemetry.api.trace.Tracer; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration#otelTracerEventPublisher matched:
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.otel.bridge.OtelTracer$EventPublisher; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration.BaggageConfiguration matched:
      - @ConditionalOnProperty (management.tracing.baggage.enabled) matched (OnPropertyCondition)

   OpenTelemetryAutoConfiguration.BaggageConfiguration#otelSlf4JBaggageEventListener matched:
      - @ConditionalOnProperty (management.tracing.baggage.correlation.enabled) matched (OnPropertyCondition)
      - @ConditionalOnMissingBean (types: io.micrometer.tracing.otel.bridge.Slf4JBaggageEventListener; SearchStrategy: all) did not find any beans (OnBeanCondition)

   OpenTelemetryAutoConfiguration.BaggageConfiguration#w3cTextMapPropagatorWithBaggage matched:
      - @ConditionalOnProperty (management.tracing.propagation.type=W3C) matched (OnPropertyCondition)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 10, 2023
@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Apr 12, 2023

Duplicate of #34508.

I'm a little bit confused since the title is about logs but the description is mostly about tracing.

For logs, you will need an extra property, e.g.:

logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]

See: sample

For tracing and OTLP, you will need this to be merged: #34508.
Right now, you can add io.opentelemetry:opentelemetry-exporter-otlp to your classpath and create an OtlpHttpSpanExporter @Bean as you see in the PR above.

I took a look at the reproducer too, there are a few issues you might want to fix:

  • Do not define io.opentelemetry.version, let the BOMs do it for you
  • You don't need spring-cloud-starter-config (nor the properties for config-server)
  • micrometer-observation, opentelemetry-sdk-trace, opentelemetry-sdk, opentelemetry-extension-trace-propagators, opentelemetry-instrumentation-annotations, micrometer-tracing are not necessary
  • You only need: web, actuator, micrometer-tracing-bridge-otel, and opentelemetry-exporter-otlp (see above)
  • You don't need @ComponentScan

As I told you in email and on Micrometer Slack about the Micrometer Samples, e.g.: https://github.com/micrometer-metrics/micrometer-samples/tree/main/micrometer-samples-boot3-web
This sample will use opentelemetry-exporter-zipkin but as I mentioned above, you should add io.opentelemetry:opentelemetry-exporter-otlp right now to your classpath and create an OtlpHttpSpanExporter @Bean as you see in #34508. Hopefully this will not be needed in Boot 3.1.

Please let us know if I misunderstood something, we can reopen this issue.

@jonatan-ivanov jonatan-ivanov closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
@jonatan-ivanov jonatan-ivanov added status: duplicate A duplicate of another issue theme: observability Issues related to observability and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue theme: observability Issues related to observability
Projects
None yet
Development

No branches or pull requests

3 participants