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
OTLP metric exporter - resource attributes not exported #3208
Comments
@alanwest what version of the collector was used in the example? |
I built and ran the collector locally from main. |
It looks like opentelemetry-go/sdk/metric/pipeline.go Line 171 in 038248b
|
This exists for the package main
import (
"context"
"log"
"time"
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
)
func main() {
ctx := context.Background()
exporter, err := stdoutmetric.New()
if err != nil {
log.Fatalf("failed to create metric exporter: %v", err)
}
reader := metric.NewPeriodicReader(
exporter,
metric.WithInterval(time.Second),
)
res := resource.NewWithAttributes(
semconv.SchemaURL,
// This attribute is not exported
semconv.ServiceNameKey.String("my-service"),
)
log.Println("resource:", res)
meterProvider := metric.NewMeterProvider(
metric.WithResource(res),
metric.WithReader(reader),
)
meter := meterProvider.Meter("my-meter")
counter, err := meter.SyncFloat64().Counter("my-counter")
if err != nil {
log.Fatalf("failed to initialize instrument: %v", err)
}
counter.Add(ctx, 12.0)
time.Sleep(2 * time.Second)
err = meterProvider.Shutdown(ctx)
if err != nil {
log.Fatalln("failed to shutdown", err)
}
} go 1.19
require (
go.opentelemetry.io/otel v1.10.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.32.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.32.0
go.opentelemetry.io/otel/sdk v1.10.0
go.opentelemetry.io/otel/sdk/metric v0.32.0
)
require (
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.32.0 // indirect
go.opentelemetry.io/otel/metric v0.32.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
) |
Validated with the above examples #3218 should resolve this. |
* Set MeterProvider resource for all pipelines Resolves #3208 * Add change to changelog
I'm still experiencing this on the latest ( otelRes := resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("test server"),
semconv.ServiceVersion("v0.1.0"),
attribute.String("foo", "bar"), // we expect this to be propagated
) I'm not seeing the "foo=bar" attribute propagated in the metric. I hacked my way through this to solve it but it doesn't feel right, please have a look at this test where I'm replicating the issue. |
The resource seems to be propagated as is, I checked the gRPC client as well so the fact that I don't see |
@fracasula please open a new bug. The bug described by this issue is still fixed according to the validation it contains. |
|
Description
Resource attributes are not exported using the OTLP metric exporter.
Environment
Steps To Reproduce
Expected behavior
Resource should include the attribute
service.name=my-service
The text was updated successfully, but these errors were encountered: