Skip to content

Issue with AttributeKey.type #1317

@jens-at-collectum

Description

@jens-at-collectum

We're using micrometer to instrument the code and AzureMonitorTraceExporter to send traces to Azure's application insight.

As far as I can see there's an issue in how micrometer is bridging cardinalityKeys to otel.

When an observation is stopped, the TracingObservationHandler(s) tags the span with all cardinalityKeys in:

    default void tagSpan(T context, Span span) {
        for (KeyValue keyValue : context.getAllKeyValues()) {
            if (!keyValue.getKey().equalsIgnoreCase("ERROR")) {
                span.tag(keyValue.getKey(), keyValue.getValue());
            }
            else {
                span.error(new RuntimeException(keyValue.getValue()));
            }
        }
    }

However, TracingObservationHandler.spanTag() implicitly converts all AttributeKeys to string keys, spanTag() uses keyValue.getKey() keyValue.getValue(), which will eventually invoke Span.setAttribute(String, String) which creates a string key.

  default Span setAttribute(String key, @Nullable String value) {
    return setAttribute(AttributeKey.stringKey(key), value);
  }

According to otel, should for example ttp.response.status_code be a longKey:

    AttributeKey<Long> HTTP_RESPONSE_STATUS_CODE = longKey("http.response.status_code");

The effect is that AzureMonitor, in this case, is unable to map spans to theit TelemetryItems, and most tags/attributes will be considered custom tags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions