Skip to content

Commit 99d1142

Browse files
committed
feat: store OTEL process context in named anonymous mapping on Linux
1 parent 32c3ebe commit 99d1142

File tree

5 files changed

+428
-0
lines changed

5 files changed

+428
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed
2+
// under the Apache License Version 2.0.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
// Copyright 2025 Datadog, Inc.
5+
package tracer
6+
7+
// OtelProcessContext represents the OTEL context for the process.
8+
//
9+
//go:generate go run github.com/tinylib/msgp -unexported -marshal=true -o=otelprocesscontext_msgp.go -tests=false
10+
type otelProcessContext struct {
11+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-environment-name
12+
DeploymentEnvironmentName string `msg:"deployment.environment.name"`
13+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/host/#host-name
14+
HostName string `msg:"host.name"`
15+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-instance-id
16+
ServiceInstanceID string `msg:"service.instance.id"`
17+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-name
18+
ServiceName string `msg:"service.name"`
19+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-version
20+
ServiceVersion string `msg:"service.version"`
21+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/telemetry/#telemetry-sdk-language
22+
TelemetrySdkLanguage string `msg:"telemetry.sdk.language"`
23+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/telemetry/#telemetry-sdk-version
24+
TelemetrySdkVersion string `msg:"telemetry.sdk.version"`
25+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/telemetry/#telemetry-sdk-name
26+
TelemetrySdkName string `msg:"telemetry.sdk.name"`
27+
}

ddtrace/tracer/otelprocesscontext_msgp.go

Lines changed: 285 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ddtrace/tracer/tracer.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,23 @@ func storeConfig(c *config) {
287287
if err != nil {
288288
log.Error("failed to store the configuration: %s", err.Error())
289289
}
290+
291+
processContext := otelProcessContext{
292+
DeploymentEnvironmentName: c.env,
293+
HostName: c.hostname,
294+
ServiceInstanceID: globalconfig.RuntimeID(),
295+
ServiceName: c.serviceName,
296+
ServiceVersion: c.version,
297+
TelemetrySdkLanguage: "go",
298+
TelemetrySdkVersion: version.Tag,
299+
TelemetrySdkName: "dd-trace-go",
300+
}
301+
302+
data, _ = processContext.MarshalMsg(nil)
303+
err = globalinternal.CreateOtelProcessContextMapping(data)
304+
if err != nil {
305+
log.Error("failed to store the OTEL process context: %s", err.Error())
306+
}
290307
}
291308

292309
// Stop stops the started tracer. Subsequent calls are valid but become no-op.

internal/otelcontextmapping.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed
2+
// under the Apache License Version 2.0.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
// Copyright 2025 Datadog, Inc.
5+
6+
//go:build !linux
7+
8+
package internal
9+
10+
func CreateOtelProcessContextMapping(data []byte) error {
11+
return nil
12+
}

0 commit comments

Comments
 (0)