package grpc import ( "context" "fmt" "gitoa.ru/go-4devs/otel/meter" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" "go.opentelemetry.io/otel/sdk/metric" ) func With(endpoint string, options ...otlpmetricgrpc.Option) func(context.Context, *meter.Option) error { return func(ctx context.Context, o *meter.Option) error { if len(options) == 0 { options = append(options, otlpmetricgrpc.WithInsecure(), otlpmetricgrpc.WithEndpoint(endpoint)) } exp, err := otlpmetricgrpc.New(ctx, options...) if err != nil { return fmt.Errorf("create otlpmetricgrpc: %w", err) } return meter.WithReader(metric.NewPeriodicReader(exp))(ctx, o) } }