open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.92k stars 2.28k forks source link

[connector/spanmetricsconnector] status.code returning STATUS_CODE_UNSET #25896

Closed karmingc closed 1 year ago

karmingc commented 1 year ago

Component(s)

connector/spanmetrics

What happened?

Description

Currently configured spanmetrics, but I am seeing a STATUS_CODE_UNSET within the status.code metric albeit it being set in the span. Not too sure what's missing from the configuration...

This is currently configured using Micrometer (in Spring Boot).

Steps to Reproduce

  1. Create an application and send a trace of your choice, make sure one of the spans contain the status.code attribute.
  2. Set up OpenTelemetry collector with the same configuration.

Expected Result

The status.code should not be STATUS_CODE_UNSET and be the same as the one in the span.

Actual Result

The status.code is STATUS_CODE_UNSET.

Collector version

0.83.0

Environment information

Environment

Ran with Docker

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
      http:

exporters:
  zipkin:
    endpoint: http://host.docker.internal:9411/api/v2/spans
  logging:
    verbosity: detailed
    sampling_initial: 10
    sampling_thereafter: 50

connectors:
  spanmetrics:
    histogram:
      exponential:
    aggregation_temporality: AGGREGATION_TEMPORALITY_DELTA
    dimensions:
      - name: http.host
      - name: http.path_group
    exclude_dimensions:
      - span.kind
      - span.name
      - service.name

processors:
  batch:
  filter/spanmetrics:
    traces:
      span:
        - 'kind.string != "Client"'
  metricstransform/spanmetrics:
    transforms:
      - include: "duration"
        action: update
        new_name: "http.client.request.test"
        match_type: regexp
        experimental_match_labels:
          {
            "http.host": "(.|\\s)*\\S(.|\\s)*",
            "http.path_group": "(.|\\s)*\\S(.|\\s)*",
          }
      - include: "calls"
        action: update
        new_name: "http.client.request.hits.test"
        match_type: regexp
        experimental_match_labels:
          {
            "http.host": "(.|\\s)*\\S(.|\\s)*",
            "http.path_group": "(.|\\s)*\\S(.|\\s)*",
          }

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions: [pprof, zpages, health_check]
  pipelines:
    traces/spanmetrics:
      receivers: [otlp]
      processors: [batch, filter/spanmetrics]
      exporters: [logging, spanmetrics] # logging
    metrics/spanmetrics:
      receivers: [spanmetrics]
      processors: [batch, metricstransform/spanmetrics]
      exporters: [logging]
  telemetry:
    logs:
      level: "debug"

Log output

otel-otel-collector-1  | 2023-08-18T18:25:14.991Z   info    ResourceSpans #0
otel-otel-collector-1  | Resource SchemaURL:
otel-otel-collector-1  | Resource attributes:
otel-otel-collector-1  |      -> service.name: Str(svc)
otel-otel-collector-1  |      -> telemetry.sdk.language: Str(java)
otel-otel-collector-1  |      -> telemetry.sdk.name: Str(opentelemetry)
otel-otel-collector-1  |      -> telemetry.sdk.version: Str(1.25.0)
otel-otel-collector-1  | ScopeSpans #0
otel-otel-collector-1  | ScopeSpans SchemaURL:
otel-otel-collector-1  | InstrumentationScope org.springframework.boot 3.1.2
otel-otel-collector-1  | Span #0
otel-otel-collector-1  |     Trace ID       : 52b8f46c3bdce31966f287bae15dab8b
otel-otel-collector-1  |     Parent ID      :
otel-otel-collector-1  |     ID             : 0d39d71c7708e8c2
otel-otel-collector-1  |     Name           : http post /api/users/jwt_token
otel-otel-collector-1  |     Kind           : Client
otel-otel-collector-1  |     Start time     : 2023-08-18 18:25:10.472042 +0000 UTC
otel-otel-collector-1  |     End time       : 2023-08-18 18:25:11.144612419 +0000 UTC
otel-otel-collector-1  |     Status code    : Unset
otel-otel-collector-1  |     Status message :
otel-otel-collector-1  | Attributes:
otel-otel-collector-1  |      -> exception: Str(none)
otel-otel-collector-1  |      -> http.host: Str(host)
otel-otel-collector-1  |      -> http.path_group: Str(/api/users/jwt_token)
otel-otel-collector-1  |      -> status.code: Str(200)
otel-otel-collector-1  | 2023-08-18T18:25:17.601Z   info    ResourceMetrics #0
otel-otel-collector-1  | Resource SchemaURL:
otel-otel-collector-1  | Resource attributes:
otel-otel-collector-1  |      -> service.name: Str(svc)
otel-otel-collector-1  |      -> telemetry.sdk.language: Str(java)
otel-otel-collector-1  |      -> telemetry.sdk.name: Str(opentelemetry)
otel-otel-collector-1  |      -> telemetry.sdk.version: Str(1.25.0)
otel-otel-collector-1  | ScopeMetrics #0
otel-otel-collector-1  | ScopeMetrics SchemaURL:
otel-otel-collector-1  | InstrumentationScope spanmetricsconnector
otel-otel-collector-1  | Metric #0
otel-otel-collector-1  | Descriptor:
otel-otel-collector-1  |      -> Name: http.client.request.hits.test
otel-otel-collector-1  |      -> Description:
otel-otel-collector-1  |      -> Unit:
otel-otel-collector-1  |      -> DataType: Sum
otel-otel-collector-1  |      -> IsMonotonic: true
otel-otel-collector-1  |      -> AggregationTemporality: Delta
otel-otel-collector-1  | NumberDataPoints #0
otel-otel-collector-1  | Data point attributes:
otel-otel-collector-1  |      -> status.code: Str(STATUS_CODE_UNSET)
otel-otel-collector-1  |      -> http.host: Str(host)
otel-otel-collector-1  |      -> http.path_group: Str(/api/users/jwt_token)
otel-otel-collector-1  | StartTimestamp: 2023-08-18 18:25:02.530779715 +0000 UTC
otel-otel-collector-1  | Timestamp: 2023-08-18 18:25:17.531134243 +0000 UTC
otel-otel-collector-1  | Value: 1
otel-otel-collector-1  | Metric #1
otel-otel-collector-1  | Descriptor:
otel-otel-collector-1  |      -> Name: http.client.request.test
otel-otel-collector-1  |      -> Description:
otel-otel-collector-1  |      -> Unit: ms
otel-otel-collector-1  |      -> DataType: Histogram
otel-otel-collector-1  |      -> AggregationTemporality: Delta
otel-otel-collector-1  | HistogramDataPoints #0
otel-otel-collector-1  | Data point attributes:
otel-otel-collector-1  |      -> status.code: Str(STATUS_CODE_UNSET)
otel-otel-collector-1  |      -> http.host: Str(host)
otel-otel-collector-1  |      -> http.path_group: Str(/api/users/jwt_token)
otel-otel-collector-1  | StartTimestamp: 2023-08-18 18:25:02.530779715 +0000 UTC
otel-otel-collector-1  | Timestamp: 2023-08-18 18:25:17.53113719 +0000 UTC
otel-otel-collector-1  | Count: 1
otel-otel-collector-1  | Sum: 672.570419
otel-otel-collector-1  | ExplicitBounds #0: 2.000000
otel-otel-collector-1  | ExplicitBounds #1: 4.000000
otel-otel-collector-1  | ExplicitBounds #2: 6.000000
otel-otel-collector-1  | ExplicitBounds #3: 8.000000
otel-otel-collector-1  | ExplicitBounds #4: 10.000000
otel-otel-collector-1  | ExplicitBounds #5: 50.000000
otel-otel-collector-1  | ExplicitBounds #6: 100.000000
otel-otel-collector-1  | ExplicitBounds #7: 200.000000
otel-otel-collector-1  | ExplicitBounds #8: 400.000000
otel-otel-collector-1  | ExplicitBounds #9: 800.000000
otel-otel-collector-1  | ExplicitBounds #10: 1000.000000
otel-otel-collector-1  | ExplicitBounds #11: 1400.000000
otel-otel-collector-1  | ExplicitBounds #12: 2000.000000
otel-otel-collector-1  | ExplicitBounds #13: 5000.000000
otel-otel-collector-1  | ExplicitBounds #14: 10000.000000
otel-otel-collector-1  | ExplicitBounds #15: 15000.000000
otel-otel-collector-1  | Buckets #0, Count: 0
otel-otel-collector-1  | Buckets #1, Count: 0
otel-otel-collector-1  | Buckets #2, Count: 0
otel-otel-collector-1  | Buckets #3, Count: 0
otel-otel-collector-1  | Buckets #4, Count: 0
otel-otel-collector-1  | Buckets #5, Count: 0
otel-otel-collector-1  | Buckets #6, Count: 0
otel-otel-collector-1  | Buckets #7, Count: 0
otel-otel-collector-1  | Buckets #8, Count: 0
otel-otel-collector-1  | Buckets #9, Count: 1
otel-otel-collector-1  | Buckets #10, Count: 0
otel-otel-collector-1  | Buckets #11, Count: 0
otel-otel-collector-1  | Buckets #12, Count: 0
otel-otel-collector-1  | Buckets #13, Count: 0
otel-otel-collector-1  | Buckets #14, Count: 0
otel-otel-collector-1  | Buckets #15, Count: 0
otel-otel-collector-1  | Buckets #16, Count: 0

Additional context

No response

github-actions[bot] commented 1 year ago

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

karmingc commented 1 year ago

It seems like I got some configuration confused, it seems like within the span metadata, the Status code is UNSET. I'm assuming the root cause might be within Micrometer…