-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[datadog/connector] Create a simplified Trace to Trace connector (#31026
) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Datadog Connector is creating two instances of Trace Agent, one in the trace-to-metrics pipeline and another in the traces-to-traces pipeline. The PR separates the trace-to-trace connector, simplifying the logic, this avoid un-necessary serialization. **Link to tracking Issue:** <Issue number if applicable> #30828 #30487 **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.>
- Loading branch information
Showing
7 changed files
with
108 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. filelogreceiver) | ||
component: datadog/connector | ||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Create a separate connector in the Datadog connector for the trace-to-metrics and trace-to-trace pipelines. It should reduce the number of conversions we do and help with Datadog connector performance. | ||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [30828] | ||
# (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: Simplify datadog/connector with two separate connectors in trace-to-metrics pipeline and trace-to-trace pipeline. | ||
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package datadogconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// keyStatsComputed specifies the resource attribute key which indicates if stats have been | ||
// computed for the resource spans. | ||
const keyStatsComputed = "_dd.stats_computed" | ||
|
||
type traceToTraceConnector struct { | ||
logger *zap.Logger | ||
tracesConsumer consumer.Traces // the next component in the pipeline to ingest traces after connector | ||
} | ||
|
||
func newTraceToTraceConnector(logger *zap.Logger, nextConsumer consumer.Traces) *traceToTraceConnector { | ||
logger.Info("Building datadog connector for trace to trace") | ||
return &traceToTraceConnector{ | ||
logger: logger, | ||
tracesConsumer: nextConsumer, | ||
} | ||
} | ||
|
||
// Start implements the component interface. | ||
func (c *traceToTraceConnector) Start(_ context.Context, _ component.Host) error { | ||
return nil | ||
} | ||
|
||
// Shutdown implements the component interface. | ||
func (c *traceToTraceConnector) Shutdown(_ context.Context) error { | ||
return nil | ||
} | ||
|
||
// Capabilities implements the consumer interface. | ||
// tells use whether the component(connector) will mutate the data passed into it. if set to true the connector does modify the data | ||
func (c *traceToTraceConnector) Capabilities() consumer.Capabilities { | ||
return consumer.Capabilities{MutatesData: true} // ConsumeTraces puts a new attribute _dd.stats_computed | ||
} | ||
|
||
// ConsumeTraces implements the consumer interface. | ||
func (c *traceToTraceConnector) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error { | ||
for i := 0; i < traces.ResourceSpans().Len(); i++ { | ||
rs := traces.ResourceSpans().At(i) | ||
// Stats will be computed for p. Mark the original resource spans to ensure that they don't | ||
// get computed twice in case these spans pass through here again. | ||
rs.Resource().Attributes().PutBool(keyStatsComputed, true) | ||
|
||
} | ||
return c.tracesConsumer.ConsumeTraces(ctx, traces) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters