Skip to content
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

Add ddprofilingextension #33156

Merged
merged 43 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b2686c5
Add ddprofilingextension
mackjmr Jan 21, 2025
3b04f8c
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Jan 21, 2025
0d8abea
fix tidy/ modules
mackjmr Jan 21, 2025
aed0849
re-add toolchain
mackjmr Jan 21, 2025
3af3008
add env,svc,version config
mackjmr Jan 21, 2025
221ece5
leverage trace-agent from otel-agent cfg
mackjmr Jan 22, 2025
7cc5901
fix linter
mackjmr Jan 22, 2025
b39b517
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Jan 22, 2025
97d2c4f
shutdown server
mackjmr Jan 22, 2025
3fd6848
component report status
mackjmr Jan 22, 2025
19b1d6e
OCB test
mackjmr Jan 22, 2025
4635ae9
add test
mackjmr Jan 24, 2025
7ceeeaa
fix shutdown and add tests for OSS
mackjmr Jan 24, 2025
fe936bf
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Jan 24, 2025
7aa6ad6
enhance tests and add profiler options
mackjmr Jan 27, 2025
59091f7
inv tidy
mackjmr Jan 27, 2025
f39f3d0
inv tidy
mackjmr Jan 27, 2025
d638703
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Jan 27, 2025
b339816
comment OCB test
mackjmr Jan 27, 2025
d8593a1
add readme
mackjmr Jan 27, 2025
72d4fd0
nits
mackjmr Jan 27, 2025
00ed9e3
address feedback
mackjmr Jan 28, 2025
4f6bf1a
add test duplicate patterns
mackjmr Jan 28, 2025
f0599c5
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Jan 29, 2025
533d012
fix lint
mackjmr Jan 29, 2025
f3c1dca
feedback
mackjmr Jan 30, 2025
cd4d0b8
used_by_otel: true
mackjmr Jan 30, 2025
e8b5759
lint & license
mackjmr Jan 31, 2025
46b7547
fix lint
mackjmr Jan 31, 2025
ae38e43
fmt
mackjmr Jan 31, 2025
e0b928a
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Feb 3, 2025
974b3b6
add replace
mackjmr Feb 3, 2025
ad57e64
lint
mackjmr Feb 3, 2025
d675013
add ignore in modules.py
mackjmr Feb 3, 2025
723a441
fix lint
mackjmr Feb 3, 2025
abf0c38
fix lint
mackjmr Feb 3, 2025
40b368e
Update comp/otelcol/ddprofilingextension/README.md
mackjmr Feb 3, 2025
4d52639
feedback
mackjmr Feb 3, 2025
e1b4473
addressed feedback
mackjmr Feb 3, 2025
8a04448
Lint
mackjmr Feb 3, 2025
17de05b
inv tidy
mackjmr Feb 3, 2025
21228ed
Merge branch 'main' into mackjmr/ddprofilingextension
mackjmr Feb 4, 2025
d540f3e
fix test after merge main
mackjmr Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ core,github.com/DataDog/go-libddwaf/v3/internal/log,Apache-2.0,"Copyright 2016-p
core,github.com/DataDog/go-libddwaf/v3/internal/support,Apache-2.0,"Copyright 2016-present Datadog, Inc"
core,github.com/DataDog/go-libddwaf/v3/internal/unsafe,Apache-2.0,"Copyright 2016-present Datadog, Inc"
core,github.com/DataDog/go-libddwaf/v3/timer,Apache-2.0,"Copyright 2016-present Datadog, Inc"
core,github.com/DataDog/go-runtime-metrics-internal/pkg/runtimemetrics,Apache-2.0,"Copyright 2024-2024 Datadog, Inc"
core,github.com/DataDog/go-sqllexer,MIT,"Copyright (c) 2023 Datadog, Inc"
core,github.com/DataDog/go-tuf/client,BSD-3-Clause,"Copyright (c) 2014-2020 Prime Directive, Inc. All rights reserved"
core,github.com/DataDog/go-tuf/data,BSD-3-Clause,"Copyright (c) 2014-2020 Prime Directive, Inc. All rights reserved"
Expand Down Expand Up @@ -3030,6 +3031,7 @@ core,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/listener/usersec,Apache-2.0
core,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/listener/waf,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/constants,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/utils,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/utils/telemetry,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/datastreams,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
Expand Down
4 changes: 4 additions & 0 deletions comp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ Package converter defines the otel agent converter component.

Package ddflareextension defines the OpenTelemetry Extension component.

### [comp/otelcol/ddprofilingextension](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/otelcol/ddprofilingextension)

Package ddprofilingextension defines the otel agent ddprofilingextension component.

### [comp/otelcol/logsagentpipeline](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline)

Package logsagentpipeline contains logs agent pipeline component
Expand Down
2 changes: 2 additions & 0 deletions comp/otelcol/collector/impl/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
collectorcontrib "github.com/DataDog/datadog-agent/comp/otelcol/collector-contrib/def"
collector "github.com/DataDog/datadog-agent/comp/otelcol/collector/def"
ddextension "github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/impl"
ddprofilingextension "github.com/DataDog/datadog-agent/comp/otelcol/ddprofilingextension/impl"
"github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline"
"github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/datadogexporter"
"github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/serializerexporter"
Expand Down Expand Up @@ -132,6 +133,7 @@ func addFactories(reqs Requires, factories otelcol.Factories) {
factories.Processors[infraattributesprocessor.Type] = infraattributesprocessor.NewFactoryForAgent(reqs.Tagger)
factories.Connectors[component.MustNewType("datadog")] = datadogconnector.NewFactory()
factories.Extensions[ddextension.Type] = ddextension.NewFactoryForAgent(&factories, newConfigProviderSettings(reqs.URIs, reqs.Converter, false))
factories.Extensions[ddprofilingextension.Type] = ddprofilingextension.NewFactoryForAgent(reqs.TraceAgent, reqs.Log)
}

var buildInfo = component.BuildInfo{
Expand Down
38 changes: 38 additions & 0 deletions comp/otelcol/ddprofilingextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ddprofiling Extension

The ddprofiling extension allows profiling the collector via the datadog profiler.

## Extension Configuration

- api: API allows specifying `api::key` and `api::site`. This is only effective when the extension is used in the OSS collector built via OCB. In this case, the profiles are sent directly to the intake using the API key and site specified.
- profiler_options: Profiler options allows configuring options that pertain to the profiler, such as service/env/version, or period (in seconds).
- endpoint: In the OTel agent, the extension spins up an http server which receives the profiles and sends them to DD intake. You can change the endpoint at which the server listens via this config (default port `7501`)


Example Config OSS collector:
```
extensions:
ddprofiling:
api:
key: ${env:DD_API_KEY}
site: ${env:DD_SITE}
```

Example Config OTel Agent:
```
extensions:
ddprofiling:
endpoint: 1234
```

Example profiler options config:
```
extensions:
ddprofiling:
profiler_options:
service: svc
version: v0.1
env: env
period: 30
profile_types: [blockprofile, mutexprofile, goroutineprofile]
```
16 changes: 16 additions & 0 deletions comp/otelcol/ddprofilingextension/def/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024-present Datadog, Inc.

// Package ddprofilingextension defines the otel agent ddprofilingextension component.
package ddprofilingextension

import "go.opentelemetry.io/collector/extension"

// team: opentelemetry opentelemetry-agent

// Component implements the component.Component interface.
type Component interface {
extension.Extension // Embed base Extension for common functionality.
mackjmr marked this conversation as resolved.
Show resolved Hide resolved
}
26 changes: 26 additions & 0 deletions comp/otelcol/ddprofilingextension/def/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module github.com/DataDog/datadog-agent/comp/otelcol/ddprofilingextension/def

go 1.22.0

require go.opentelemetry.io/collector/extension v0.118.0

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
go.opentelemetry.io/collector/component v0.118.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.118.0 // indirect
go.opentelemetry.io/collector/pdata v1.24.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250127172529-29210b9bc287 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
)
87 changes: 87 additions & 0 deletions comp/otelcol/ddprofilingextension/def/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions comp/otelcol/ddprofilingextension/fx/fx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024-present Datadog, Inc.

// Package ddprofilingextensionfx provides fx access for the provider component
package ddprofilingextensionfx

import (
ddprofilingextension "github.com/DataDog/datadog-agent/comp/otelcol/ddprofilingextension/def"
ddprofilingextensionimpl "github.com/DataDog/datadog-agent/comp/otelcol/ddprofilingextension/impl"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
)

// team: opentelemetry opentelemetry-agent

// Module defines the fx options for this component.
func Module() fxutil.Module {
return fxutil.Component(
fxutil.ProvideComponentConstructor(ddprofilingextensionimpl.NewExtension),
fxutil.ProvideOptional[ddprofilingextension.Component](),
)
}
41 changes: 41 additions & 0 deletions comp/otelcol/ddprofilingextension/impl/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024-present Datadog, Inc.

// Package ddprofilingextensionimpl defines the OpenTelemetry Extension implementation.
package ddprofilingextensionimpl

import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config"

// Config contains the config of the profiler.
type Config struct {
// API contains the configuration for the api for the case of agentless uploads.
// api site is used in non agentless upload setups as well.
// Not setting API section leads to upload to an agent with.
API config.APIConfig `mapstructure:"api"`
ProfilerOptions ProfilerOptions `mapstructure:"profiler_options"`
// Endpoint reports the endpoint used for profiles.
// Default: BuildInfo.Version (e.g. v0.117.0)
Endpoint string `mapstructure:"endpoint"`
}

// ProfilerOptions defines settings relevant to the profiler.
type ProfilerOptions struct {
// Service the profiler will report with.
// Default: BuildInfo.Command (e.g. otel-agent)
Service string `mapstructure:"service"`
// Env the profiler will report with.
// Default: none
Env string `mapstructure:"env"`
dineshg13 marked this conversation as resolved.
Show resolved Hide resolved
// Version the profiler will report with.
// Default: BuildInfo.Version (e.g. v0.117.0)
Version string `mapstructure:"version"`
// Period in seconds the profiler will report with.
// Default: 60s
Period int `mapstructure:"period"`
// ProfileTypes specifies additional profile types to enable.
// supported values are blockprofile, mutexprofile and goroutineprofile.
// By default CPU and Heap profiles are enabled.
ProfileTypes []string `mapstructure:"profile_types"`
}
Loading
Loading