From fc22a95cc197d738bbbe5f7a8a4e1fd04146abc8 Mon Sep 17 00:00:00 2001 From: Jonathan Lee <107072447+jj22ee@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:53:26 -0700 Subject: [PATCH] [exporter/awsxray] Change exporter.awsxray.skiptimestampvalidation feature gate from Alpha to Beta (#26553) **Description:** Change `exporter.awsxray.skiptimestampvalidation` feature gate from Alpha to Beta. This will change the `awsxrayexporter` to not drop invalid trace ids (first 32-bits of trace id in Unix epoch time is not within past 30 days) by default. **Link to tracking Issue:** N/A **Testing:** Updated Unit tests. Local testing: Used [Golang OTel instrumented sample app](https://github.com/aws-observability/aws-otel-community/tree/master/centralized-sampling-tests/sample-apps/golang-http-server) Built the ADOT Collector locally with [the timestamp check removal change](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/26041), and ran locally with feature gate enabled Scenarios tested with XRay Service (drops W3C trace): - Removed the ID Generator in Golang sample app, created a few traces with W3C trace ID - result: Collector logs indicate that XRay has dropped the segments - Created a batch of traces with W3C trace ID and XRay trace ID - result: Collector logs indicate that XRay has dropped only the w3c segments Example logs from XRay logged by awsxrayexporter due to invalid trace IDs sent to XRay: ``` 2023-09-07T17:29:30.495Z debug awsxrayexporter@v0.83.0/awsxray.go:79 response: { UnprocessedTraceSegments: [{ ErrorCode: "InvalidTraceId", Id: "33f5358b5290fbc8", Message: "Invalid segment. ErrorCode: InvalidTraceId" },{ ErrorCode: "InvalidTraceId", Id: "6be91641d130c356", Message: "Invalid segment. ErrorCode: InvalidTraceId" }] } {"kind": "exporter", "data_type": "traces", "name": "awsxray"} ``` **Documentation:** Updated awsxrayexporter README to indicate that the exporter will not drop the traces with invalid trace ids anymore. Let X-Ray handle the logic for dropping the traces instead. --------- Co-authored-by: Anthony Mirabella --- ...ray-exporter-w3c-id-beta-feature-gate.yaml | 27 +++++++++++++++++++ exporter/awsxrayexporter/README.md | 6 ++--- exporter/awsxrayexporter/awsxray_test.go | 6 ++--- exporter/awsxrayexporter/factory.go | 2 +- exporter/awsxrayexporter/factory_test.go | 2 +- 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 .chloggen/xray-exporter-w3c-id-beta-feature-gate.yaml diff --git a/.chloggen/xray-exporter-w3c-id-beta-feature-gate.yaml b/.chloggen/xray-exporter-w3c-id-beta-feature-gate.yaml new file mode 100644 index 000000000000..263717d1270c --- /dev/null +++ b/.chloggen/xray-exporter-w3c-id-beta-feature-gate.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# 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. filelogreceiver) +component: awsxrayexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Change `exporter.awsxray.skiptimestampvalidation` feature gate from Alpha to Beta" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [26553] + +# (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: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# 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: [user] diff --git a/exporter/awsxrayexporter/README.md b/exporter/awsxrayexporter/README.md index c5a3a5fb8921..e8898f731be6 100644 --- a/exporter/awsxrayexporter/README.md +++ b/exporter/awsxrayexporter/README.md @@ -26,10 +26,10 @@ propagated by them using the `X-Amzn-Trace-Id` HTTP header. However, other gener supported by replacing fully-random Trace IDs with X-Ray formatted Trace IDs where necessary: > AWS X-Ray IDs are the same size as W3C Trace Context IDs but differ in that the first 32 bits of a Trace ID -> is the Unix epoch time when the trace was started. Since X-Ray only allows submission of Trace IDs from the -> past 30 days, received Trace IDs are checked and spans without a valid timestamp are dropped. +> is the Unix epoch time when the trace was started. Note that X-Ray only allows submission of Trace IDs from +> the past 30 days, otherwise the trace is dropped by X-Ray. The Exporter will not validate this timestamp. -This means in order for spans to appear in X-Ray, the client SDK MUST use an X-Ray ID generator. For more +This means that until X-Ray supports Trace Ids consisting of fully random bits, in order for spans to appear in X-Ray, the client SDK MUST use an X-Ray ID generator. For more information, see [configuring the X-Ray exporter](https://aws-otel.github.io/docs/getting-started/x-ray#configuring-the-aws-x-ray-exporter). diff --git a/exporter/awsxrayexporter/awsxray_test.go b/exporter/awsxrayexporter/awsxray_test.go index bd5d84e74607..3f7fc4d6bdf2 100644 --- a/exporter/awsxrayexporter/awsxray_test.go +++ b/exporter/awsxrayexporter/awsxray_test.go @@ -56,14 +56,13 @@ func TestXrayAndW3CSpanTraceExport(t *testing.T) { func TestXrayAndW3CSpanTraceResourceExtraction(t *testing.T) { td := constructXrayAndW3CSpanData() logger, _ := zap.NewProduction() - assert.Len(t, extractResourceSpans(generateConfig(t), logger, td), 2, "2 spans have xay trace id") + assert.Len(t, extractResourceSpans(generateConfig(t), logger, td), 4, "4 spans have xray/w3c trace id") } func TestW3CSpanTraceResourceExtraction(t *testing.T) { - t.Skip("Flaky test, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9255") td := constructW3CSpanData() logger, _ := zap.NewProduction() - assert.Len(t, extractResourceSpans(generateConfig(t), logger, td), 0, "0 spans have xray trace id") + assert.Len(t, extractResourceSpans(generateConfig(t), logger, td), 2, "2 spans have w3c trace id") } func TestTelemetryEnabled(t *testing.T) { @@ -137,7 +136,6 @@ func constructSpanData() ptrace.Traces { return traces } -// nolint:unused func constructW3CSpanData() ptrace.Traces { resource := constructResource() traces := ptrace.NewTraces() diff --git a/exporter/awsxrayexporter/factory.go b/exporter/awsxrayexporter/factory.go index 258f086bf26e..60343357f1e9 100644 --- a/exporter/awsxrayexporter/factory.go +++ b/exporter/awsxrayexporter/factory.go @@ -17,7 +17,7 @@ import ( var skipTimestampValidationFeatureGate = featuregate.GlobalRegistry().MustRegister( "exporter.awsxray.skiptimestampvalidation", - featuregate.StageAlpha, + featuregate.StageBeta, featuregate.WithRegisterDescription("Remove XRay's timestamp validation on first 32 bits of trace ID"), featuregate.WithRegisterFromVersion("v0.84.0")) diff --git a/exporter/awsxrayexporter/factory_test.go b/exporter/awsxrayexporter/factory_test.go index e457f5abe17f..321eb82a7601 100644 --- a/exporter/awsxrayexporter/factory_test.go +++ b/exporter/awsxrayexporter/factory_test.go @@ -36,7 +36,7 @@ func TestCreateDefaultConfig(t *testing.T) { ResourceARN: "", RoleARN: "", }, - skipTimestampValidation: false, + skipTimestampValidation: true, }, "failed to create default config") assert.NoError(t, componenttest.CheckConfigStruct(cfg)) }