Skip to content

OpenTelemetry exporter fails to cast attribute and drops tracing batch #1241

@wmolde

Description

@wmolde

Hi, we're running into an issue where our OpenTelemetry exporter crashes when it attempt to process some of the tracing spans that originate from the OkHttpRequestAdapter It appears that there is a SERVER_PORT attribute being used that is defined as a stringKey. However the data being set for that key is a long (or possibly an in). Either way when we run our application our exporter crashes out with the following error. This is causing all of the traces in the batch to be dropped, so we are also loosing critical application details.

Application error log:

|14:51:17.133|ERROR|                         S.err:  Apr 30, 2024 2:51:17 PM io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker exportCurrentBatch
|14:51:17.133|ERROR|                         S.err:  WARNING: Exporter threw an Exception
|14:51:17.133|ERROR|                         S.err:  java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler.create(KeyValueMarshaler.java:68)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler.access$000(KeyValueMarshaler.java:30)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler$1.accept(KeyValueMarshaler.java:47)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler$1.accept(KeyValueMarshaler.java:42)
|14:51:17.133|ERROR|                         S.err:     at java.base/java.util.HashMap.forEach(HashMap.java:1421)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.sdk.internal.AttributesMap.forEach(AttributesMap.java:88)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler.createRepeated(KeyValueMarshaler.java:41)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.traces.SpanMarshaler.create(SpanMarshaler.java:44)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.marshal.MarshalerUtil.groupByResourceAndScope(MarshalerUtil.java:67)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.traces.ResourceSpansMarshaler.groupByResourceAndScope(ResourceSpansMarshaler.java:95)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.traces.ResourceSpansMarshaler.create(ResourceSpansMarshaler.java:36)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler.create(TraceRequestMarshaler.java:32)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter.export(OtlpGrpcSpanExporter.java:54)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker.exportCurrentBatch(BatchSpanProcessor.java:326)
|14:51:17.133|ERROR|                         S.err:     at io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker.run(BatchSpanProcessor.java:244)
|14:51:17.133|ERROR|                         S.err:     at java.base/java.lang.Thread.run(Thread.java:840)
|14:51:17.133|ERROR|                         S.err:
|

Attribute that we traced as being the root cause: spanForAttributes.setAttribute(SERVER_PORT, requestURL.getPort())
Atrribute definition that we believe to be the issue: public static final AttributeKey SERVER_PORT = stringKey("server.port")

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtype:bugA broken experience

Type

No type

Projects

Status

Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions