Skip to content

Commit 1e7b8b3

Browse files
TylerHelmuthf7o
authored andcommitted
[pkg/ottl] Remove tracing from OTTL (open-telemetry#34910)
**Description:** Reverts open-telemetry#33508 since it was causing performance issues **Link to tracking Issue:** <Issue number if applicable> Reopens open-telemetry#33433 Related to open-telemetry/opentelemetry-collector#10858 Closes open-telemetry#34890
1 parent 9d6e54f commit 1e7b8b3

File tree

6 files changed

+42
-265
lines changed

6 files changed

+42
-265
lines changed

.chloggen/ottl-remove-tracing.yaml

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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove tracing from OTTL due to performance concerns
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: [34910]
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: []

pkg/ottl/README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,3 @@ service:
151151
2024-05-29T16:38:09.600-0600 debug [email protected]/parser.go:268 TransformContext after statement execution {"kind": "processor", "name": "transform", "pipeline": "logs", "statement": "set(instrumentation_scope.attributes[\"test\"], [\"pass\"])", "condition matched": true, "TransformContext": {"resource": {"attributes": {"test": "pass"}, "dropped_attribute_count": 0}, "scope": {"attributes": {"test": ["pass"]}, "dropped_attribute_count": 0, "name": "", "version": ""}, "log_record": {"attributes": {"log.file.name": "test.log"}, "body": "test", "dropped_attribute_count": 0, "flags": 0, "observed_time_unix_nano": 1717022289500721000, "severity_number": 0, "severity_text": "", "span_id": "", "time_unix_nano": 0, "trace_id": ""}, "cache": {}}}
152152
2024-05-29T16:38:09.601-0600 debug [email protected]/parser.go:268 TransformContext after statement execution {"kind": "processor", "name": "transform", "pipeline": "logs", "statement": "set(attributes[\"test\"], true)", "condition matched": true, "TransformContext": {"resource": {"attributes": {"test": "pass"}, "dropped_attribute_count": 0}, "scope": {"attributes": {"test": ["pass"]}, "dropped_attribute_count": 0, "name": "", "version": ""}, "log_record": {"attributes": {"log.file.name": "test.log", "test": true}, "body": "test", "dropped_attribute_count": 0, "flags": 0, "observed_time_unix_nano": 1717022289500721000, "severity_number": 0, "severity_text": "", "span_id": "", "time_unix_nano": 0, "trace_id": ""}, "cache": {}}}
153153
```
154-
155-
If configured to do so, the collector also emits traces for the execution of OTTL statement sequences.
156-
These traces contain spans for the execution of each statement, including the statement itself and whether it has
157-
been applied or not. To make use of this, enable the self monitoring of the collector by setting the
158-
`--feature-gates=telemetry.useOtelWithSDKConfigurationForInternalTelemetry` flag, and using the following configuration
159-
to export the traces to e.g. an OTLP API endpoint:
160-
161-
```yaml
162-
service:
163-
telemetry:
164-
traces:
165-
processors:
166-
- batch:
167-
exporter:
168-
otlp:
169-
protocol: http/protobuf
170-
endpoint: ${env:OTLP_ENDPOINT}/v1/traces
171-
```

pkg/ottl/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ require (
1616
go.opentelemetry.io/collector/component v0.108.1
1717
go.opentelemetry.io/collector/pdata v1.14.1
1818
go.opentelemetry.io/collector/semconv v0.108.1
19-
go.opentelemetry.io/otel v1.29.0
20-
go.opentelemetry.io/otel/sdk v1.29.0
2119
go.opentelemetry.io/otel/trace v1.29.0
2220
go.uber.org/goleak v1.3.0
2321
go.uber.org/zap v1.27.0
@@ -45,11 +43,13 @@ require (
4543
github.com/prometheus/common v0.55.0 // indirect
4644
github.com/prometheus/procfs v0.15.1 // indirect
4745
go.opentelemetry.io/collector/config/configtelemetry v0.108.1 // indirect
46+
go.opentelemetry.io/otel v1.29.0 // indirect
4847
go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect
4948
go.opentelemetry.io/otel/metric v1.29.0 // indirect
49+
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
5050
go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect
5151
go.uber.org/multierr v1.11.0 // indirect
52-
golang.org/x/sys v0.24.0 // indirect
52+
golang.org/x/sys v0.23.0 // indirect
5353
golang.org/x/text v0.17.0 // indirect
5454
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
5555
google.golang.org/grpc v1.65.0 // indirect

pkg/ottl/go.sum

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

pkg/ottl/parser.go

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,9 @@ import (
1010

1111
"github.com/alecthomas/participle/v2"
1212
"go.opentelemetry.io/collector/component"
13-
"go.opentelemetry.io/otel/attribute"
14-
"go.opentelemetry.io/otel/codes"
15-
"go.opentelemetry.io/otel/trace"
16-
"go.opentelemetry.io/otel/trace/noop"
1713
"go.uber.org/zap"
1814
)
1915

20-
const (
21-
logAttributeTraceID = "trace_id"
22-
logAttributeSpanID = "span_id"
23-
)
24-
2516
// Statement holds a top level Statement for processing telemetry data. A Statement is a combination of a function
2617
// invocation and the boolean expression to match telemetry for invoking the function.
2718
type Statement[K any] struct {
@@ -240,7 +231,6 @@ type StatementSequence[K any] struct {
240231
statements []*Statement[K]
241232
errorMode ErrorMode
242233
telemetrySettings component.TelemetrySettings
243-
tracer trace.Tracer
244234
}
245235

246236
type StatementSequenceOption[K any] func(*StatementSequence[K])
@@ -260,10 +250,6 @@ func NewStatementSequence[K any](statements []*Statement[K], telemetrySettings c
260250
statements: statements,
261251
errorMode: PropagateError,
262252
telemetrySettings: telemetrySettings,
263-
tracer: &noop.Tracer{},
264-
}
265-
if telemetrySettings.TracerProvider != nil {
266-
s.tracer = telemetrySettings.TracerProvider.Tracer("ottl")
267253
}
268254
for _, op := range options {
269255
op(&s)
@@ -276,62 +262,20 @@ func NewStatementSequence[K any](statements []*Statement[K], telemetrySettings c
276262
// When the ErrorMode of the StatementSequence is `ignore`, errors are logged and execution continues to the next statement.
277263
// When the ErrorMode of the StatementSequence is `silent`, errors are not logged and execution continues to the next statement.
278264
func (s *StatementSequence[K]) Execute(ctx context.Context, tCtx K) error {
279-
ctx, sequenceSpan := s.tracer.Start(ctx, "ottl/StatementSequenceExecution")
280-
defer sequenceSpan.End()
281-
s.telemetrySettings.Logger.Debug(
282-
"initial TransformContext",
283-
zap.Any("TransformContext", tCtx),
284-
zap.String(logAttributeTraceID, sequenceSpan.SpanContext().TraceID().String()),
285-
zap.String(logAttributeSpanID, sequenceSpan.SpanContext().SpanID().String()),
286-
)
265+
s.telemetrySettings.Logger.Debug("initial TransformContext", zap.Any("TransformContext", tCtx))
287266
for _, statement := range s.statements {
288-
statementCtx, statementSpan := s.tracer.Start(ctx, "ottl/StatementExecution")
289-
statementSpan.SetAttributes(
290-
attribute.KeyValue{
291-
Key: "statement",
292-
Value: attribute.StringValue(statement.origText),
293-
},
294-
)
295-
_, condition, err := statement.Execute(statementCtx, tCtx)
296-
statementSpan.SetAttributes(
297-
attribute.KeyValue{
298-
Key: "condition.matched",
299-
Value: attribute.BoolValue(condition),
300-
},
301-
)
302-
s.telemetrySettings.Logger.Debug(
303-
"TransformContext after statement execution",
304-
zap.String("statement", statement.origText),
305-
zap.Bool("condition matched", condition),
306-
zap.Any("TransformContext", tCtx),
307-
zap.String(logAttributeTraceID, statementSpan.SpanContext().TraceID().String()),
308-
zap.String(logAttributeSpanID, statementSpan.SpanContext().SpanID().String()),
309-
)
267+
_, condition, err := statement.Execute(ctx, tCtx)
268+
s.telemetrySettings.Logger.Debug("TransformContext after statement execution", zap.String("statement", statement.origText), zap.Bool("condition matched", condition), zap.Any("TransformContext", tCtx))
310269
if err != nil {
311-
statementSpan.RecordError(err)
312-
errMsg := fmt.Sprintf("failed to execute statement '%s': %v", statement.origText, err)
313-
statementSpan.SetStatus(codes.Error, errMsg)
314270
if s.errorMode == PropagateError {
315-
sequenceSpan.SetStatus(codes.Error, errMsg)
316-
statementSpan.End()
317271
err = fmt.Errorf("failed to execute statement: %v, %w", statement.origText, err)
318272
return err
319273
}
320274
if s.errorMode == IgnoreError {
321-
s.telemetrySettings.Logger.Warn(
322-
"failed to execute statement",
323-
zap.Error(err),
324-
zap.String("statement", statement.origText),
325-
zap.String(logAttributeTraceID, statementSpan.SpanContext().TraceID().String()),
326-
zap.String(logAttributeSpanID, statementSpan.SpanContext().SpanID().String()),
327-
)
275+
s.telemetrySettings.Logger.Warn("failed to execute statement", zap.Error(err), zap.String("statement", statement.origText))
328276
}
329-
} else {
330-
statementSpan.SetStatus(codes.Ok, "statement executed successfully")
331277
}
332-
statementSpan.End()
333278
}
334-
sequenceSpan.SetStatus(codes.Ok, "statement sequence executed successfully")
335279
return nil
336280
}
337281

0 commit comments

Comments
 (0)