-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework live debugging for otel components
- Loading branch information
Showing
31 changed files
with
392 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
internal/component/otelcol/internal/interceptorconsumer/logs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package interceptorconsumer | ||
|
||
import ( | ||
"context" | ||
|
||
otelconsumer "go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/plog" | ||
) | ||
|
||
type LogsInterceptorFunc func(context.Context, plog.Logs) error | ||
|
||
type LogsInterceptor struct { | ||
onConsumeLogs LogsInterceptorFunc | ||
nextLogs otelconsumer.Logs | ||
mutatesData bool // must be set to true if the provided opts modifies the data | ||
} | ||
|
||
func Logs(nextLogs otelconsumer.Logs, mutatesData bool, f LogsInterceptorFunc) otelconsumer.Logs { | ||
return &LogsInterceptor{ | ||
nextLogs: nextLogs, | ||
mutatesData: mutatesData, | ||
onConsumeLogs: f, | ||
} | ||
} | ||
|
||
func (i *LogsInterceptor) Capabilities() otelconsumer.Capabilities { | ||
return otelconsumer.Capabilities{MutatesData: i.mutatesData} | ||
} | ||
|
||
func (i *LogsInterceptor) ConsumeLogs(ctx context.Context, ld plog.Logs) error { | ||
|
||
if i.onConsumeLogs != nil { | ||
return i.onConsumeLogs(ctx, ld) | ||
} | ||
|
||
return i.nextLogs.ConsumeLogs(ctx, ld) | ||
} |
37 changes: 37 additions & 0 deletions
37
internal/component/otelcol/internal/interceptorconsumer/metrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package interceptorconsumer | ||
|
||
import ( | ||
"context" | ||
|
||
otelconsumer "go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
) | ||
|
||
type MetricsInterceptorFunc func(context.Context, pmetric.Metrics) error | ||
|
||
type MetricsInterceptor struct { | ||
onConsumeMetrics MetricsInterceptorFunc | ||
nextMetrics otelconsumer.Metrics | ||
mutatesData bool // must be set to true if the provided opts modifies the data | ||
} | ||
|
||
func Metrics(nextMetrics otelconsumer.Metrics, mutatesData bool, f MetricsInterceptorFunc) otelconsumer.Metrics { | ||
return &MetricsInterceptor{ | ||
nextMetrics: nextMetrics, | ||
mutatesData: mutatesData, | ||
onConsumeMetrics: f, | ||
} | ||
} | ||
|
||
func (i *MetricsInterceptor) Capabilities() otelconsumer.Capabilities { | ||
return otelconsumer.Capabilities{MutatesData: i.mutatesData} | ||
} | ||
|
||
func (i *MetricsInterceptor) ConsumeMetrics(ctx context.Context, ld pmetric.Metrics) error { | ||
|
||
if i.onConsumeMetrics != nil { | ||
return i.onConsumeMetrics(ctx, ld) | ||
} | ||
|
||
return i.nextMetrics.ConsumeMetrics(ctx, ld) | ||
} |
37 changes: 37 additions & 0 deletions
37
internal/component/otelcol/internal/interceptorconsumer/traces.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package interceptorconsumer | ||
|
||
import ( | ||
"context" | ||
|
||
otelconsumer "go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
type TracesInterceptorFunc func(context.Context, ptrace.Traces) error | ||
|
||
type TracesInterceptor struct { | ||
onConsumeTraces TracesInterceptorFunc | ||
nextTraces otelconsumer.Traces | ||
mutatesData bool // must be set to true if the provided opts modifies the data | ||
} | ||
|
||
func Traces(nextTraces otelconsumer.Traces, mutatesData bool, f TracesInterceptorFunc) otelconsumer.Traces { | ||
return &TracesInterceptor{ | ||
nextTraces: nextTraces, | ||
mutatesData: mutatesData, | ||
onConsumeTraces: f, | ||
} | ||
} | ||
|
||
func (i *TracesInterceptor) Capabilities() otelconsumer.Capabilities { | ||
return otelconsumer.Capabilities{MutatesData: i.mutatesData} | ||
} | ||
|
||
func (i *TracesInterceptor) ConsumeTraces(ctx context.Context, ld ptrace.Traces) error { | ||
|
||
if i.onConsumeTraces != nil { | ||
return i.onConsumeTraces(ctx, ld) | ||
} | ||
|
||
return i.nextTraces.ConsumeTraces(ctx, ld) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.