Skip to content

Commit fae5b26

Browse files
authored
[OTEL-2552] Part 1 Datadog Extension (#39590)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add initial PR for Datadog Extension <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #39589 <!--Describe what testing was performed and which tests were added.--> #### Testing only limited tests for config; no extension functionality added yet <!--Describe the documentation added.--> #### Documentation README.md, chloggen <!--Please delete paragraphs that you did not use before submitting.-->
1 parent b8e6079 commit fae5b26

26 files changed

+816
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: new_component
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: datadogextension
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Introduce framework for Datadog Extension
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39589]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ extension/azureauthextension/ @open-telemetry
9191
extension/basicauthextension/ @open-telemetry/collector-contrib-approvers @frzifus
9292
extension/bearertokenauthextension/ @open-telemetry/collector-contrib-approvers @frzifus
9393
extension/cgroupruntimeextension/ @open-telemetry/collector-contrib-approvers @mx-psi @rogercoll
94+
extension/datadogextension/ @open-telemetry/collector-contrib-approvers @jackgopack4 @dineshg13 @mx-psi @songy23
9495
extension/encoding/ @open-telemetry/collector-contrib-approvers @atoulme @dao-jun @dmitryax @MovieStoreGuy @VihasMakwana
9596
extension/encoding/avrologencodingextension/ @open-telemetry/collector-contrib-approvers @thmshmm
9697
extension/encoding/awscloudwatchmetricstreamsencodingextension/ @open-telemetry/collector-contrib-approvers @axw @constanca-m

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ body:
9494
- extension/basicauth
9595
- extension/bearertokenauth
9696
- extension/cgroupruntime
97+
- extension/datadog
9798
- extension/encoding
9899
- extension/encoding/avrologencoding
99100
- extension/encoding/awscloudwatchmetricstreamsencoding

.github/ISSUE_TEMPLATE/feature_request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ body:
8888
- extension/basicauth
8989
- extension/bearertokenauth
9090
- extension/cgroupruntime
91+
- extension/datadog
9192
- extension/encoding
9293
- extension/encoding/avrologencoding
9394
- extension/encoding/awscloudwatchmetricstreamsencoding

.github/ISSUE_TEMPLATE/other.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ body:
8888
- extension/basicauth
8989
- extension/bearertokenauth
9090
- extension/cgroupruntime
91+
- extension/datadog
9192
- extension/encoding
9293
- extension/encoding/avrologencoding
9394
- extension/encoding/awscloudwatchmetricstreamsencoding

.github/ISSUE_TEMPLATE/unmaintained.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ body:
9393
- extension/basicauth
9494
- extension/bearertokenauth
9595
- extension/cgroupruntime
96+
- extension/datadog
9697
- extension/encoding
9798
- extension/encoding/avrologencoding
9899
- extension/encoding/awscloudwatchmetricstreamsencoding

.github/component_labels.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extension/azureauthextension extension/azureauth
7272
extension/basicauthextension extension/basicauth
7373
extension/bearertokenauthextension extension/bearertokenauth
7474
extension/cgroupruntimeextension extension/cgroupruntime
75+
extension/datadogextension extension/datadog
7576
extension/encoding extension/encoding
7677
extension/encoding/avrologencodingextension extension/encoding/avrologencoding
7778
extension/encoding/awscloudwatchmetricstreamsencodingextension extension/encoding/awscloudwatchmetricstreams

extension/datadogextension/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common

extension/datadogextension/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Datadog Extension
2+
<!-- status autogenerated section -->
3+
| Status | |
4+
| ------------- |-----------|
5+
| Stability | [development] |
6+
| Distributions | [] |
7+
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fdatadog%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fdatadog) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fdatadog%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fdatadog) |
8+
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@jackgopack4](https://www.github.com/jackgopack4), [@dineshg13](https://www.github.com/dineshg13), [@mx-psi](https://www.github.com/mx-psi), [@songy23](https://www.github.com/songy23) |
9+
10+
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development
11+
<!-- end autogenerated section -->
12+
13+
This is the initial version of the Datadog Extension. It is in development and not guaranteed to work in any specific way prior to collector infrastructure monitoring features being announced or launched by Datadog.
14+
15+
You can configure this extension in service, using the following configuration values:
16+
`api::key`: a Datadog API Key, required
17+
`api::site`: your Datadog site value (e.g. us5.datadoghq.com), defaults to "datadoghq.com"
18+
`hostname`: custom hostname; if you do not specify one, the extension will try to infer one. Note: this must match any hostname value set in the `host_metadata` section of Datadog Exporter, if also enabled in your collector.

extension/datadogextension/config.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package datadogextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/datadogextension"
5+
6+
import (
7+
"fmt"
8+
"strings"
9+
10+
"go.opentelemetry.io/collector/component"
11+
"go.opentelemetry.io/collector/config/confighttp"
12+
13+
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/datadogextension/internal/httpserver"
14+
datadogconfig "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config"
15+
)
16+
17+
var _ component.Config = (*Config)(nil)
18+
19+
// Config contains the information necessary for enabling the Datadog Extension.
20+
type Config struct {
21+
confighttp.ClientConfig `mapstructure:",squash"`
22+
// Define the site and API key (and whether to fail on invalid API key) in API.
23+
API datadogconfig.APIConfig `mapstructure:"api"`
24+
// If Hostname is empty extension will use available system APIs and cloud provider endpoints.
25+
Hostname string `mapstructure:"hostname"`
26+
// HTTPConfig is v2 config for the http metadata service.
27+
HTTPConfig *httpserver.Config `mapstructure:"http"`
28+
}
29+
30+
// Validate ensures that the configuration is valid.
31+
func (c *Config) Validate() error {
32+
if c.API.Site == "" {
33+
return datadogconfig.ErrEmptyEndpoint
34+
}
35+
if c.API.Key == "" {
36+
return datadogconfig.ErrUnsetAPIKey
37+
}
38+
invalidAPIKeyChars := datadogconfig.NonHexRegex.FindAllString(string(c.API.Key), -1)
39+
if len(invalidAPIKeyChars) > 0 {
40+
return fmt.Errorf("%w: invalid characters: %s", datadogconfig.ErrAPIKeyFormat, strings.Join(invalidAPIKeyChars, ", "))
41+
}
42+
return nil
43+
}

0 commit comments

Comments
 (0)