Skip to content

Commit 175494a

Browse files
authored
Merge branch 'open-telemetry:main' into update
2 parents b6cc285 + 8c74228 commit 175494a

File tree

9 files changed

+294
-316
lines changed

9 files changed

+294
-316
lines changed

.chloggen/dd-logger.yaml

+27
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/datadog
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Expose the internal Zaplogger implementation
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: [37939]
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: [api]

exporter/datadogexporter/agent_components.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import (
1212
pkgconfigmodel "github.com/DataDog/datadog-agent/pkg/config/model"
1313
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
1414
"go.opentelemetry.io/collector/component"
15+
16+
pkgdatadog "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog"
1517
)
1618

1719
func newLogComponent(set component.TelemetrySettings) corelog.Component {
18-
zlog := &zaplogger{
19-
logger: set.Logger,
20+
zlog := &pkgdatadog.Zaplogger{
21+
Logger: set.Logger,
2022
}
2123
return zlog
2224
}

exporter/datadogexporter/traces_exporter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,6 @@ func newTraceAgentConfig(ctx context.Context, params exporter.Settings, cfg *Con
254254
if !datadog.ReceiveResourceSpansV2FeatureGate.IsEnabled() {
255255
acfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
256256
}
257-
tracelog.SetLogger(&zaplogger{params.Logger}) // TODO: This shouldn't be a singleton
257+
tracelog.SetLogger(&datadog.Zaplogger{Logger: params.Logger}) // TODO: This shouldn't be a singleton
258258
return acfg, nil
259259
}

exporter/datadogexporter/zaplogger.go

-80
This file was deleted.

pkg/datadog/go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog
33
go 1.23.0
44

55
require (
6+
github.com/DataDog/datadog-agent/pkg/trace v0.62.2
67
github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.62.2
78
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.25.0
89
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.25.0
@@ -34,7 +35,7 @@ require (
3435
github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.25.0 // indirect
3536
github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.25.0 // indirect
3637
github.com/DataDog/sketches-go v1.4.6 // indirect
37-
github.com/DataDog/zstd v1.5.2 // indirect
38+
github.com/DataDog/zstd v1.5.6 // indirect
3839
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.26.0 // indirect
3940
github.com/aws/aws-sdk-go-v2 v1.36.1 // indirect
4041
github.com/aws/aws-sdk-go-v2/config v1.29.6 // indirect
@@ -136,7 +137,7 @@ require (
136137
golang.org/x/sys v0.29.0 // indirect
137138
golang.org/x/term v0.28.0 // indirect
138139
golang.org/x/text v0.21.0 // indirect
139-
golang.org/x/time v0.7.0 // indirect
140+
golang.org/x/time v0.8.0 // indirect
140141
google.golang.org/genproto/googleapis/rpc v0.0.0-20241230172942-26aa7a208def // indirect
141142
google.golang.org/grpc v1.70.0 // indirect
142143
google.golang.org/protobuf v1.36.5 // indirect

pkg/datadog/go.sum

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/datadog/zaplogger.go

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package datadog // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog"
5+
6+
import (
7+
"fmt"
8+
9+
tracelog "github.com/DataDog/datadog-agent/pkg/trace/log"
10+
"go.uber.org/zap"
11+
)
12+
13+
var _ tracelog.Logger = &Zaplogger{}
14+
15+
// Zaplogger implements the tracelog.Logger interface on top of a zap.Logger
16+
type Zaplogger struct {
17+
// Logger is the internal zap logger
18+
Logger *zap.Logger
19+
}
20+
21+
// Trace implements Logger.
22+
func (z *Zaplogger) Trace(_ ...any) { /* N/A */ }
23+
24+
// Tracef implements Logger.
25+
func (z *Zaplogger) Tracef(_ string, _ ...any) { /* N/A */ }
26+
27+
// Debug implements Logger.
28+
func (z *Zaplogger) Debug(v ...any) {
29+
z.Logger.Debug(fmt.Sprint(v...))
30+
}
31+
32+
// Debugf implements Logger.
33+
func (z *Zaplogger) Debugf(format string, params ...any) {
34+
z.Logger.Debug(fmt.Sprintf(format, params...))
35+
}
36+
37+
// Info implements Logger.
38+
func (z *Zaplogger) Info(v ...any) {
39+
z.Logger.Info(fmt.Sprint(v...))
40+
}
41+
42+
// Infof implements Logger.
43+
func (z *Zaplogger) Infof(format string, params ...any) {
44+
z.Logger.Info(fmt.Sprintf(format, params...))
45+
}
46+
47+
// Warn implements Logger.
48+
func (z *Zaplogger) Warn(v ...any) error {
49+
z.Logger.Warn(fmt.Sprint(v...))
50+
return nil
51+
}
52+
53+
// Warnf implements Logger.
54+
func (z *Zaplogger) Warnf(format string, params ...any) error {
55+
z.Logger.Warn(fmt.Sprintf(format, params...))
56+
return nil
57+
}
58+
59+
// Error implements Logger.
60+
func (z *Zaplogger) Error(v ...any) error {
61+
z.Logger.Error(fmt.Sprint(v...))
62+
return nil
63+
}
64+
65+
// Errorf implements Logger.
66+
func (z *Zaplogger) Errorf(format string, params ...any) error {
67+
z.Logger.Error(fmt.Sprintf(format, params...))
68+
return nil
69+
}
70+
71+
// Critical implements Logger.
72+
func (z *Zaplogger) Critical(v ...any) error {
73+
z.Logger.Error(fmt.Sprint(v...), zap.Bool("critical", true))
74+
return nil
75+
}
76+
77+
// Criticalf implements Logger.
78+
func (z *Zaplogger) Criticalf(format string, params ...any) error {
79+
z.Logger.Error(fmt.Sprintf(format, params...), zap.Bool("critical", true))
80+
return nil
81+
}
82+
83+
// Flush implements Logger.
84+
func (z *Zaplogger) Flush() {
85+
_ = z.Logger.Sync()
86+
}

pkg/ottl/README.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@ This package implements everything necessary to use OTTL in a Collector componen
1818
- [Troubleshooting](#troubleshooting)
1919
- [Resources](#resources)
2020

21+
2122
## Getting Started
2223

23-
If you're looking to write OTTL statements for a component's configuration check out these resources.
24+
An OTTL statement is made up of 2 parts:
25+
1. A function that transforms telemetry
26+
2. Optionally, a condition that determines whether the function is executed.
27+
28+
Here is an example OTTL statement:
29+
30+
```
31+
set(span.attributes["test"], "pass") where span.attributes["test"] == nil
32+
```
33+
34+
This statement sets a new span attribute named `"test"` with a value of `"pass"` whenever the span does not already
35+
have an attribute named `"test"`. In this example, the **function** is `set`, which uses the second parameter to set the value of the first parameter, and the **condition** is `span.attributes["test"] == nil`.
2436

25-
See [OTTL Functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#ottl-functions) for a list of functions available for use in the OTTL statements of most components.
37+
Within a statement you utilize OTTL Paths to access telemetry. The example uses the Path `span.attributes` to access
38+
the span's attributes. For each Open Telemetry Signal, OTTL has a Path to every field (plus some extras to help make
39+
interacting with the data easier).
2640

27-
OTTL Contexts define how you access the fields on a given telemetry item. See the table to find the exact list of available fields:
41+
To see a list of available Paths for each Open Telemetry Signal, checkout the links below.
2842

2943
| Telemetry | OTTL Context |
3044
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
@@ -36,7 +50,17 @@ OTTL Contexts define how you access the fields on a given telemetry item. See th
3650
| `Datapoint` | [DataPoint](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottldatapoint/README.md) |
3751
| `Log` | [Log](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottllog/README.md) |
3852

39-
To understand what OTTL offers as a language, check out [OTTL's grammar doc](./LANGUAGE.md).
53+
OTTL does not support cross-signal interactions at this time. That means you cannot write a statement like
54+
55+
```
56+
set(span.attributes["log body"], log.body)
57+
```
58+
59+
See [OTTL Functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#ottl-functions) for a list of functions available for use in OTTL statements of most components.
60+
61+
To see more examples of OTTL statements, checkout the [Transform Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md#examples)
62+
63+
There is a lot more OTTL can do, like nested functions, arithmetic, indexing, and enums. To explore it further check out [OTTL's grammar doc](./LANGUAGE.md).
4064

4165
## Where to use OTTL
4266

0 commit comments

Comments
 (0)