From efc630acf1631365efbcaca3f8ddf3f92f9f27cd Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Wed, 24 Jul 2024 06:59:14 -0700 Subject: [PATCH 1/3] [chore] Update release.md (#10714) Rotate the schedule to the next release. --- docs/release.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release.md b/docs/release.md index 8263765c9e8..c139c9bb4ce 100644 --- a/docs/release.md +++ b/docs/release.md @@ -160,7 +160,6 @@ Once a module is ready to be released under the `1.x` version scheme, file a PR | Date | Version | Release manager | |------------|----------|---------------------------------------------------| -| 2024-07-15 | v0.105.0 | [@atoulme](https://github.com/atoulme) | | 2024-07-29 | v0.106.0 | [@songy23](https://github.com/songy23) | | 2024-08-12 | v0.107.0 | [@dmitryax](https://github.com/dmitryax) | | 2024-08-26 | v0.108.0 | [@codeboten](https://github.com/codeboten) | @@ -170,3 +169,4 @@ Once a module is ready to be released under the `1.x` version scheme, file a PR | 2024-10-21 | v0.112.0 | [@evan-bradley](https://github.com/evan-bradley) | | 2024-11-04 | v0.113.0 | [@djaglowski](https://github.com/djaglowski) | | 2024-11-18 | v0.114.0 | [@TylerHelmuth](https://github.com/TylerHelmuth) | +| 2024-12-02 | v0.115.0 | [@atoulme](https://github.com/atoulme) | From 68fb07b953262857d41e107a542d8b1038ad859a Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Wed, 24 Jul 2024 07:32:59 -0700 Subject: [PATCH 2/3] [exporterhelper] Update metric units (#10655) #### Description Updated the metric units for metrics in the `exporterhelper`. As described in the issue, `1` isn't an informative unit to use, so this should hopefully clarify metrics for users. #### Link to tracking issue Fixes https://github.com/open-telemetry/opentelemetry-collector/issues/10648 --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- .chloggen/exporterhelper_metric_units.yaml | 25 +++++++++++++++++++ exporter/exporterhelper/documentation.md | 22 ++++++++-------- .../internal/metadata/generated_telemetry.go | 22 ++++++++-------- exporter/exporterhelper/metadata.yaml | 22 ++++++++-------- 4 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 .chloggen/exporterhelper_metric_units.yaml diff --git a/.chloggen/exporterhelper_metric_units.yaml b/.chloggen/exporterhelper_metric_units.yaml new file mode 100644 index 00000000000..de6a645ffe3 --- /dev/null +++ b/.chloggen/exporterhelper_metric_units.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: exporterhelper + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Update units for internal telemetry + +# One or more tracking issues or pull requests related to the change +issues: [10648] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/exporter/exporterhelper/documentation.md b/exporter/exporterhelper/documentation.md index 1279ece2db9..a82163a2bfa 100644 --- a/exporter/exporterhelper/documentation.md +++ b/exporter/exporterhelper/documentation.md @@ -12,7 +12,7 @@ Number of log records failed to be added to the sending queue. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {records} | Sum | Int | true | ### otelcol_exporter_enqueue_failed_metric_points @@ -20,7 +20,7 @@ Number of metric points failed to be added to the sending queue. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {datapoints} | Sum | Int | true | ### otelcol_exporter_enqueue_failed_spans @@ -28,7 +28,7 @@ Number of spans failed to be added to the sending queue. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {spans} | Sum | Int | true | ### otelcol_exporter_queue_capacity @@ -36,7 +36,7 @@ Fixed capacity of the retry queue (in batches) | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | -| 1 | Gauge | Int | +| {batches} | Gauge | Int | ### otelcol_exporter_queue_size @@ -44,7 +44,7 @@ Current size of the retry queue (in batches) | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | -| 1 | Gauge | Int | +| {batches} | Gauge | Int | ### otelcol_exporter_send_failed_log_records @@ -52,7 +52,7 @@ Number of log records in failed attempts to send to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {records} | Sum | Int | true | ### otelcol_exporter_send_failed_metric_points @@ -60,7 +60,7 @@ Number of metric points in failed attempts to send to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {datapoints} | Sum | Int | true | ### otelcol_exporter_send_failed_spans @@ -68,7 +68,7 @@ Number of spans in failed attempts to send to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {spans} | Sum | Int | true | ### otelcol_exporter_sent_log_records @@ -76,7 +76,7 @@ Number of log record successfully sent to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {records} | Sum | Int | true | ### otelcol_exporter_sent_metric_points @@ -84,7 +84,7 @@ Number of metric points successfully sent to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {datapoints} | Sum | Int | true | ### otelcol_exporter_sent_spans @@ -92,4 +92,4 @@ Number of spans successfully sent to destination. | Unit | Metric Type | Value Type | Monotonic | | ---- | ----------- | ---------- | --------- | -| 1 | Sum | Int | true | +| {spans} | Sum | Int | true | diff --git a/exporter/exporterhelper/internal/metadata/generated_telemetry.go b/exporter/exporterhelper/internal/metadata/generated_telemetry.go index 125863e4d10..d0b27bf441b 100644 --- a/exporter/exporterhelper/internal/metadata/generated_telemetry.go +++ b/exporter/exporterhelper/internal/metadata/generated_telemetry.go @@ -56,7 +56,7 @@ func (builder *TelemetryBuilder) InitExporterQueueCapacity(cb func() int64, opts builder.ExporterQueueCapacity, err = builder.meter.Int64ObservableGauge( "otelcol_exporter_queue_capacity", metric.WithDescription("Fixed capacity of the retry queue (in batches)"), - metric.WithUnit("1"), + metric.WithUnit("{batches}"), ) if err != nil { return err @@ -74,7 +74,7 @@ func (builder *TelemetryBuilder) InitExporterQueueSize(cb func() int64, opts ... builder.ExporterQueueSize, err = builder.meter.Int64ObservableGauge( "otelcol_exporter_queue_size", metric.WithDescription("Current size of the retry queue (in batches)"), - metric.WithUnit("1"), + metric.WithUnit("{batches}"), ) if err != nil { return err @@ -102,55 +102,55 @@ func NewTelemetryBuilder(settings component.TelemetrySettings, options ...teleme builder.ExporterEnqueueFailedLogRecords, err = builder.meter.Int64Counter( "otelcol_exporter_enqueue_failed_log_records", metric.WithDescription("Number of log records failed to be added to the sending queue."), - metric.WithUnit("1"), + metric.WithUnit("{records}"), ) errs = errors.Join(errs, err) builder.ExporterEnqueueFailedMetricPoints, err = builder.meter.Int64Counter( "otelcol_exporter_enqueue_failed_metric_points", metric.WithDescription("Number of metric points failed to be added to the sending queue."), - metric.WithUnit("1"), + metric.WithUnit("{datapoints}"), ) errs = errors.Join(errs, err) builder.ExporterEnqueueFailedSpans, err = builder.meter.Int64Counter( "otelcol_exporter_enqueue_failed_spans", metric.WithDescription("Number of spans failed to be added to the sending queue."), - metric.WithUnit("1"), + metric.WithUnit("{spans}"), ) errs = errors.Join(errs, err) builder.ExporterSendFailedLogRecords, err = builder.meter.Int64Counter( "otelcol_exporter_send_failed_log_records", metric.WithDescription("Number of log records in failed attempts to send to destination."), - metric.WithUnit("1"), + metric.WithUnit("{records}"), ) errs = errors.Join(errs, err) builder.ExporterSendFailedMetricPoints, err = builder.meter.Int64Counter( "otelcol_exporter_send_failed_metric_points", metric.WithDescription("Number of metric points in failed attempts to send to destination."), - metric.WithUnit("1"), + metric.WithUnit("{datapoints}"), ) errs = errors.Join(errs, err) builder.ExporterSendFailedSpans, err = builder.meter.Int64Counter( "otelcol_exporter_send_failed_spans", metric.WithDescription("Number of spans in failed attempts to send to destination."), - metric.WithUnit("1"), + metric.WithUnit("{spans}"), ) errs = errors.Join(errs, err) builder.ExporterSentLogRecords, err = builder.meter.Int64Counter( "otelcol_exporter_sent_log_records", metric.WithDescription("Number of log record successfully sent to destination."), - metric.WithUnit("1"), + metric.WithUnit("{records}"), ) errs = errors.Join(errs, err) builder.ExporterSentMetricPoints, err = builder.meter.Int64Counter( "otelcol_exporter_sent_metric_points", metric.WithDescription("Number of metric points successfully sent to destination."), - metric.WithUnit("1"), + metric.WithUnit("{datapoints}"), ) errs = errors.Join(errs, err) builder.ExporterSentSpans, err = builder.meter.Int64Counter( "otelcol_exporter_sent_spans", metric.WithDescription("Number of spans successfully sent to destination."), - metric.WithUnit("1"), + metric.WithUnit("{spans}"), ) errs = errors.Join(errs, err) return &builder, errs diff --git a/exporter/exporterhelper/metadata.yaml b/exporter/exporterhelper/metadata.yaml index dea17a17089..e10113eb494 100644 --- a/exporter/exporterhelper/metadata.yaml +++ b/exporter/exporterhelper/metadata.yaml @@ -12,7 +12,7 @@ telemetry: exporter_sent_spans: enabled: true description: Number of spans successfully sent to destination. - unit: "1" + unit: "{spans}" sum: value_type: int monotonic: true @@ -20,7 +20,7 @@ telemetry: exporter_send_failed_spans: enabled: true description: Number of spans in failed attempts to send to destination. - unit: "1" + unit: "{spans}" sum: value_type: int monotonic: true @@ -28,7 +28,7 @@ telemetry: exporter_enqueue_failed_spans: enabled: true description: Number of spans failed to be added to the sending queue. - unit: "1" + unit: "{spans}" sum: value_type: int monotonic: true @@ -36,7 +36,7 @@ telemetry: exporter_sent_metric_points: enabled: true description: Number of metric points successfully sent to destination. - unit: "1" + unit: "{datapoints}" sum: value_type: int monotonic: true @@ -44,7 +44,7 @@ telemetry: exporter_send_failed_metric_points: enabled: true description: Number of metric points in failed attempts to send to destination. - unit: "1" + unit: "{datapoints}" sum: value_type: int monotonic: true @@ -52,7 +52,7 @@ telemetry: exporter_enqueue_failed_metric_points: enabled: true description: Number of metric points failed to be added to the sending queue. - unit: "1" + unit: "{datapoints}" sum: value_type: int monotonic: true @@ -60,7 +60,7 @@ telemetry: exporter_sent_log_records: enabled: true description: Number of log record successfully sent to destination. - unit: "1" + unit: "{records}" sum: value_type: int monotonic: true @@ -68,7 +68,7 @@ telemetry: exporter_send_failed_log_records: enabled: true description: Number of log records in failed attempts to send to destination. - unit: "1" + unit: "{records}" sum: value_type: int monotonic: true @@ -76,7 +76,7 @@ telemetry: exporter_enqueue_failed_log_records: enabled: true description: Number of log records failed to be added to the sending queue. - unit: "1" + unit: "{records}" sum: value_type: int monotonic: true @@ -84,7 +84,7 @@ telemetry: exporter_queue_size: enabled: true description: Current size of the retry queue (in batches) - unit: "1" + unit: "{batches}" optional: true gauge: value_type: int @@ -93,7 +93,7 @@ telemetry: exporter_queue_capacity: enabled: true description: Fixed capacity of the retry queue (in batches) - unit: "1" + unit: "{batches}" optional: true gauge: value_type: int From 49ea32b28914107f97d8d819921a2fe2b0bde9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Wed, 24 Jul 2024 16:53:35 +0200 Subject: [PATCH 3/3] [configgrpc] Send UNAUTHENTICATED on auth failure (#10670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #7646 Signed-off-by: Juraci Paixão Kröhling Signed-off-by: Juraci Paixão Kröhling --- .chloggen/jpkroehling-grpc-statuscode.yaml | 12 ++++++++++++ config/configgrpc/configgrpc.go | 6 ++++-- config/configgrpc/configgrpc_test.go | 8 ++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 .chloggen/jpkroehling-grpc-statuscode.yaml diff --git a/.chloggen/jpkroehling-grpc-statuscode.yaml b/.chloggen/jpkroehling-grpc-statuscode.yaml new file mode 100644 index 00000000000..d78ef4c7a9a --- /dev/null +++ b/.chloggen/jpkroehling-grpc-statuscode.yaml @@ -0,0 +1,12 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'enhancement' + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: configgrpc + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: gRPC auth errors now return gRPC status code UNAUTHENTICATED (16) + +# One or more tracking issues or pull requests related to the change +issues: [7646] + diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index f718f25913e..951aa93a87c 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -17,12 +17,14 @@ import ( "go.opentelemetry.io/otel" "google.golang.org/grpc" "google.golang.org/grpc/balancer" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" + "google.golang.org/grpc/status" "go.opentelemetry.io/collector/client" "go.opentelemetry.io/collector/component" @@ -478,7 +480,7 @@ func authUnaryServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServe ctx, err := server.Authenticate(ctx, headers) if err != nil { - return nil, err + return nil, status.Error(codes.Unauthenticated, err.Error()) } return handler(ctx, req) @@ -493,7 +495,7 @@ func authStreamServerInterceptor(srv any, stream grpc.ServerStream, _ *grpc.Stre ctx, err := server.Authenticate(ctx, headers) if err != nil { - return err + return status.Error(codes.Unauthenticated, err.Error()) } return handler(srv, wrapServerStream(ctx, stream)) diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 0b2b1cf4cd2..1769733dea6 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -19,8 +19,10 @@ import ( "go.uber.org/zap/zaptest/observer" "google.golang.org/grpc" "google.golang.org/grpc/balancer" + "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" + "google.golang.org/grpc/status" "go.opentelemetry.io/collector/client" "go.opentelemetry.io/collector/component" @@ -1022,7 +1024,8 @@ func TestDefaultUnaryInterceptorAuthFailure(t *testing.T) { // verify assert.Nil(t, res) - assert.Equal(t, expectedErr, err) + assert.ErrorContains(t, err, expectedErr.Error()) + assert.Equal(t, codes.Unauthenticated, status.Code(err)) assert.True(t, authCalled) } @@ -1098,7 +1101,8 @@ func TestDefaultStreamInterceptorAuthFailure(t *testing.T) { err := authStreamServerInterceptor(nil, streamServer, &grpc.StreamServerInfo{}, handler, auth.NewServer(auth.WithServerAuthenticate(authFunc))) // verify - assert.Equal(t, expectedErr, err) + assert.ErrorContains(t, err, expectedErr.Error()) // unfortunately, grpc errors don't wrap the original ones + assert.Equal(t, codes.Unauthenticated, status.Code(err)) assert.True(t, authCalled) }