Skip to content

[exporter/debug] add option to only show certain attributes #13378

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

cuichenli
Copy link
Member

Description

Link to tracking issue

Initial implementation for #9372

Testing

Documentation

@cuichenli cuichenli requested review from andrzej-stencel and a team as code owners July 11, 2025 05:32
@cuichenli cuichenli requested a review from TylerHelmuth July 11, 2025 05:32
@github-actions github-actions bot added the exporter/debug Issues related to the Debug exporter label Jul 11, 2025
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 99.22481% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.51%. Comparing base (9d67bd0) to head (73ea5d6).

Files with missing lines Patch % Lines
...rter/debugexporter/internal/otlptext/databuffer.go 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13378      +/-   ##
==========================================
- Coverage   91.53%   91.51%   -0.02%     
==========================================
  Files         528      529       +1     
  Lines       29469    29544      +75     
==========================================
+ Hits        26974    27038      +64     
- Misses       1969     1976       +7     
- Partials      526      530       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -18,6 +18,10 @@ var supportedLevels map[configtelemetry.Level]struct{} = map[configtelemetry.Lev
configtelemetry.LevelDetailed: {},
}

type OutputConfig struct {
Attributes []string `mapstructure:"attributes"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defines the configuration option output::attributes as a list of attributes that user wants to see in the exporter's output. If this list is empty, all attributes are displayed in the output. In this solution, is there a way for user to configure the exporter to not display any attributes at all?

Let me propose the following alternate configuration options:

  • output::attributes::enabled (boolean, default: true) when set to false, no attributes are displayed
  • output::attributes::include (list of strings, default empty) list of attributes to display

Please let me know what you think.

@@ -60,6 +71,22 @@ func (s *debugExporter) pushTraces(_ context.Context, td ptrace.Traces) error {
return nil
}

for _, rs := range td.ResourceSpans().All() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the Debug exporter to one that mutates data. This comes with a performance penalty - the whole telemetry batch may need to be copied in memory. I'd rather keep the Debug exporter as non-mutating. Would it be possible to perform the filtering when formatting output?

@@ -60,6 +71,22 @@ func (s *debugExporter) pushTraces(_ context.Context, td ptrace.Traces) error {
return nil
}

for _, rs := range td.ResourceSpans().All() {
rs.Resource().Attributes().RemoveIf(func(k string, _ pcommon.Value) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind, the output::attributes only affects the output of record-level attributes (log record attributes, metric data point attributes, span attributes). The output of resource or scope level attributes should be governed by separate options output::resource and output::scope.

Perhaps better to name the option output::record::attributes? What do you think?

@@ -53,7 +53,7 @@ func createDefaultConfig() component.Config {
func createTraces(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Traces, error) {
cfg := config.(*Config)
exporterLogger := createLogger(cfg, set.Logger)
debug := newDebugExporter(exporterLogger, cfg.Verbosity)
debug := newDebugExporter(exporterLogger, cfg.Verbosity, cfg.Output)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just pass the whole config as a single variable?

Suggested change
debug := newDebugExporter(exporterLogger, cfg.Verbosity, cfg.Output)
debug := newDebugExporter(exporterLogger, cfg)

@cuichenli
Copy link
Member Author

All the comments make sense to me — I'll update accordingly.

Regarding filtering when formatting the output, I was thinking of adding a custom Marshaler. Do you think that would be a reasonable approach?

@andrzej-stencel
Copy link
Member

Thank you @cuichenli for this contribution. I do have a couple comments, please let me know what you think.

I've put down a more specific description of the options I have in mind on the issue #9372 (comment). Happy to hear your or others' thoughts on this.

@andrzej-stencel
Copy link
Member

Regarding filtering when formatting the output, I was thinking of adding a custom Marshaler. Do you think that would be a reasonable approach?

Feel free to propose a solution, I'll look into it.

@cuichenli
Copy link
Member Author

@andrzej-stencel updated, please take another look. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/debug Issues related to the Debug exporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants