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

Exported Int64ValueRecorder Metrics Via OTLP Missing Labels #1563

Closed
terev opened this issue Feb 20, 2021 · 1 comment · Fixed by #1570
Closed

Exported Int64ValueRecorder Metrics Via OTLP Missing Labels #1563

terev opened this issue Feb 20, 2021 · 1 comment · Fixed by #1570
Assignees
Labels
area:metrics Part of OpenTelemetry Metrics

Comments

@terev
Copy link
Contributor

terev commented Feb 20, 2021

Version: v0.16.0
Collector Version: v0.20.0

When exporting a metric via the OTLP exporter pointed at a grpc receiver in a collector. The exported metric has none of my defined labels.

metric setup:

driver := otlpgrpc.NewDriver(
  otlpgrpc.WithInsecure(),
  otlpgrpc.WithEndpoint(c.Metrics.OtelURL),
)
exporter, err := otlp.NewExporter(context.Background(), driver)
if err != nil {
  return nil, errors.Wrap(err, "failed to create exporter")
}

cont := controller.New(
  processor.New(
	  simple.NewWithExactDistribution(),
	  exporter,
  ),
  controller.WithPusher(exporter),
  controller.WithCollectPeriod(2*time.Second),
)

otel.SetMeterProvider(cont.MeterProvider())

if err := cont.Start(context.Background()); err != nil {
  return nil, err
}

return func() {
  err := cont.Stop(context.Background()) // Push any last metric events to the exporter.
  if err != nil {
	  panic(err)
  }
  exporter.Shutdown(context.Background())
}, nil
recorder, err := meter.NewInt64ValueRecorder(
  "container_image_size_bytes",
  metric.WithUnit(unit.Bytes),
  metric.WithDescription("Records uncompressed built image size"),
)
recorder.Record(ctx, size, label.Any("yo", "yo"), containerImageName.String(name), containerImageRegistry.String(registry))

I was able to hook up a debugger and trace the library to find the metric is being transformed to a gauge array https://github.com/open-telemetry/opentelemetry-go/blob/main/exporters/otlp/internal/transform/metric.go#L309 . Which makes sense but for some reason the labels on each data point are currently being set to nil. Is this a misake?

@terev terev changed the title Exported Int64ValueRecorder Metrics Via OTLP Have Empty Labels Exported Int64ValueRecorder Metrics Via OTLP Have Missing Labels Feb 20, 2021
@terev
Copy link
Contributor Author

terev commented Feb 20, 2021

I tried passing stringKeyValues(labels.Iter()) instead of nil and my labels end up being exported correctly. Is there a reason the labels aren't being passed?

@terev terev changed the title Exported Int64ValueRecorder Metrics Via OTLP Have Missing Labels Exported Int64ValueRecorder Metrics Via OTLP Missing Labels Feb 21, 2021
@MrAlias MrAlias added area:metrics Part of OpenTelemetry Metrics pkg:exporter labels Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants