-
Notifications
You must be signed in to change notification settings - Fork 3k
[connector/datadog] Add trace configs that mirror datadog exporter #30787
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d3a2676
[connector/datadog] Add trace configs that mirror datadog exporter
songy23 7ce7974
Fix changelog
songy23 72dc980
Add to README
songy23 f725217
Merge branch 'main' into ddconnector-config
songy23 b472520
Modify trace agent creation
songy23 6e814b9
Merge branch 'main' into ddconnector-config
songy23 ce6659f
Change default, add example
songy23 5752189
Fix a comment
songy23 af4e99f
lint and crosslink
songy23 4ece23b
gotidy
songy23 fabfbb3
Update connector/datadogconnector/config.go
songy23 c65e7f8
Update connector/datadogconnector/config.go
songy23 11fba2d
Update connector/datadogconnector/config.go
songy23 11f022e
Fix comments
songy23 1a2a9b0
Merge branch 'main' into ddconnector-config
songy23 c5d1eb1
Fix readme
songy23 803c508
tidy and fix test
songy23 6d99f44
Merge branch 'main' into ddconnector-config
songy23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
# 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: datadogconnector | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add trace configs that mirror datadog exporter | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [30787] | ||
|
||
# (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: | | ||
ignore_resources: disable certain traces based on their resource name | ||
span_name_remappings: map of datadog span names and preferred name to map to | ||
span_name_as_resource_name: use OTLP span name as datadog operation name | ||
compute_stats_by_span_kind: enables an additional stats computation check based on span kind | ||
peer_tags_aggregation: enables aggregation of peer related tags | ||
trace_buffer: specifies the buffer size for datadog trace payloads | ||
|
||
# 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: [] |
This file contains hidden or 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 hidden or 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,83 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package datadogconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector" | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
var _ component.Config = (*Config)(nil) | ||
|
||
type Config struct { | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// ignored resources | ||
// A blocklist of regular expressions can be provided to disable certain traces based on their resource name | ||
// all entries must be surrounded by double quotes and separated by commas. | ||
// ignore_resources: ["(GET|POST) /healthcheck"] | ||
IgnoreResources []string `mapstructure:"ignore_resources"` | ||
|
||
// SpanNameRemappings is the map of datadog span names and preferred name to map to. This can be used to | ||
// automatically map Datadog Span Operation Names to an updated value. All entries should be key/value pairs. | ||
// span_name_remappings: | ||
// io.opentelemetry.javaagent.spring.client: spring.client | ||
// instrumentation:express.server: express | ||
// go.opentelemetry.io_contrib_instrumentation_net_http_otelhttp.client: http.client | ||
SpanNameRemappings map[string]string `mapstructure:"span_name_remappings"` | ||
|
||
// If set to true the OpenTelemetry span name will used in the Datadog resource name. | ||
// If set to false the resource name will be filled with the instrumentation library name + span kind. | ||
// The default value is `false`. | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SpanNameAsResourceName bool `mapstructure:"span_name_as_resource_name"` | ||
|
||
// If set to true, enables an additional stats computation check on spans to see they have an eligible `span.kind` (server, consumer, client, producer). | ||
// If enabled, a span with an eligible `span.kind` will have stats computed. If disabled, only top-level and measured spans will have stats computed. | ||
// NOTE: For stats computed from OTel traces, only top-level spans are considered when this option is off. | ||
ComputeStatsBySpanKind bool `mapstructure:"compute_stats_by_span_kind"` | ||
|
||
// If set to true, enables aggregation of peer related tags (e.g., `peer.service`, `db.instance`, etc.) in the datadog connector. | ||
// If disabled, aggregated trace stats will not include these tags as dimensions on trace metrics. | ||
// For the best experience with peer tags, Datadog also recommends enabling `compute_stats_by_span_kind`. | ||
// If you are using an OTel tracer, it's best to have both enabled because client/producer spans with relevant peer tags | ||
// may not be marked by the datadog connector as top-level spans. | ||
// If enabling both causes the datadog connector to consume too many resources, try disabling `compute_stats_by_span_kind` first. | ||
// A high cardinality of peer tags or APM resources can also contribute to higher CPU and memory consumption. | ||
// You can check for the cardinality of these fields by making trace search queries in the Datadog UI. | ||
// The default list of peer tags can be found in https://github.com/DataDog/datadog-agent/blob/main/pkg/trace/stats/concentrator.go. | ||
PeerTagsAggregation bool `mapstructure:"peer_tags_aggregation"` | ||
|
||
// TraceBuffer specifies the number of Datadog Agent TracerPayloads to buffer before dropping. | ||
// The default value is 0, meaning the Datadog Agent TracerPayloads are unbuffered. | ||
TraceBuffer int `mapstructure:"trace_buffer"` | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// Validate the configuration for errors. This is required by component.Config. | ||
func (c *Config) Validate() error { | ||
if c.IgnoreResources != nil { | ||
for _, entry := range c.IgnoreResources { | ||
_, err := regexp.Compile(entry) | ||
if err != nil { | ||
return fmt.Errorf("'%s' is not valid resource filter regular expression", entry) | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
||
if c.SpanNameRemappings != nil { | ||
for key, value := range c.SpanNameRemappings { | ||
if value == "" { | ||
return fmt.Errorf("'%s' is not valid value for span name remapping", value) | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if key == "" { | ||
return fmt.Errorf("'%s' is not valid key for span name remapping", key) | ||
songy23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
||
if c.TraceBuffer < 0 { | ||
return fmt.Errorf("Trace buffer must be non-negative") | ||
} | ||
|
||
return nil | ||
} |
This file contains hidden or 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,76 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package datadogconnector | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidate(t *testing.T) { | ||
|
||
tests := []struct { | ||
name string | ||
cfg *Config | ||
err string | ||
}{ | ||
{ | ||
name: "span name remapping valid", | ||
cfg: &Config{ | ||
SpanNameRemappings: map[string]string{"old.opentelemetryspan.name": "updated.name"}, | ||
}, | ||
}, | ||
{ | ||
name: "span name remapping empty val", | ||
cfg: &Config{ | ||
SpanNameRemappings: map[string]string{"oldname": ""}, | ||
}, | ||
err: "'' is not valid value for span name remapping", | ||
}, | ||
{ | ||
name: "span name remapping empty key", | ||
cfg: &Config{ | ||
SpanNameRemappings: map[string]string{"": "newname"}, | ||
}, | ||
err: "'' is not valid key for span name remapping", | ||
}, | ||
{ | ||
name: "ignore resources valid", | ||
cfg: &Config{ | ||
IgnoreResources: []string{"[123]"}, | ||
}, | ||
}, | ||
{ | ||
name: "ignore resources missing bracket", | ||
cfg: &Config{ | ||
IgnoreResources: []string{"[123"}, | ||
}, | ||
err: "'[123' is not valid resource filter regular expression", | ||
}, | ||
{ | ||
name: "With trace_buffer", | ||
cfg: &Config{ | ||
TraceBuffer: 10, | ||
}, | ||
}, | ||
{ | ||
name: "neg trace_buffer", | ||
cfg: &Config{ | ||
TraceBuffer: -10, | ||
}, | ||
err: "Trace buffer must be non-negative", | ||
}, | ||
} | ||
for _, testInstance := range tests { | ||
t.Run(testInstance.name, func(t *testing.T) { | ||
err := testInstance.cfg.Validate() | ||
if testInstance.err != "" { | ||
assert.EqualError(t, err, testInstance.err) | ||
} else { | ||
assert.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.