open-telemetry / opentelemetry-collector-contrib

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

Sentry exporter: missing `library_version` for Sentry error #35307

Open afifurrohman-id opened 1 month ago

afifurrohman-id commented 1 month ago

Component(s)

exporter/sentry

What happened?

Description

base on this picture library_version is invalid in Sentry error because is empty {57D8B281-558A-49C9-B87B-9065F17042EB}

Steps to Reproduce

import ( "context" "errors" "fmt"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"

)

func check(err error) { if err != nil { panic(err) } }

func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel()

exporter, err := otlptrace.New(
    ctx,
    otlptracegrpc.NewClient(otlptracegrpc.WithInsecure(), otlptracegrpc.WithEndpoint("localhost:4317")),
)
check(err)

tp := sdktrace.NewTracerProvider(
    sdktrace.WithSampler(sdktrace.AlwaysSample()),
    sdktrace.WithBatcher(exporter),
    sdktrace.WithResource(resource.NewWithAttributes(
        semconv.SchemaURL,
        semconv.ServiceNameKey.String("foo service"),
    )),
)
defer tp.Shutdown(ctx)

otel.SetTracerProvider(tp)
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}))

ctx, span := otel.GetTracerProvider().Tracer("trace foo").Start(ctx, "span foo")
defer span.End()

err = errors.New("error foo")
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())

}

## Expected Result
`library_version` it should not empty in sentry UI
## Actual Result
give error say: `library_version is empty`

### Collector version

Docker image: `otel/opentelemetry-collector-contrib:0.106.1`

### Environment information

## Environment
OS: `Linux 🦀 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 GNU/Linux`

### OpenTelemetry Collector configuration

```yaml
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: "0.0.0.0:${env:OTLP_GRPC_PORT}"
processors:
  batch:

exporters:
  sentry:
    dsn: "${env:SENTRY_DSN}"
    insecure_skip_verify: true
  logging:
        verbosity: detailed

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions:
    - health_check
    - pprof
    - zpages
  pipelines:
    traces:
      receivers:
        - otlp
      processors:
      - batch
      exporters: [logging, sentry]
  telemetry:
    logs:
      level: DEBUG

Log output

none

Additional context

none

github-actions[bot] commented 1 month ago

Pinging code owners:

AbhiPrasad commented 1 month ago

We probably want to do some extra validation here: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/f02bdf9cd8f4a42a80df711e1add0ecb4f6b1dab/exporter/sentryexporter/sentry_exporter.go#L271-L272

@afifurrohman-id would you be open to create a PR?

crobert-1 commented 1 month ago

Removing needs triage based on response from code owner validating that this is a real issue.