Skip to content

Conversation

Angith
Copy link
Contributor

@Angith Angith commented Sep 12, 2025

This PR enables Go Tracer to disable log spans at tracer level.

There are four ways to disable log spans:

  1. Using Code
  2. Using Environment Variables
  3. Using Configuration File
  4. Using agent configuration

@Angith Angith requested a review from a team as a code owner September 12, 2025 11:24
@Angith Angith marked this pull request as draft September 12, 2025 11:25
@Angith Angith self-assigned this Sep 15, 2025
@Angith Angith marked this pull request as ready for review September 16, 2025 07:10
@Angith Angith added the tekton_ci Add this label to start running Tekton pipelines label Sep 16, 2025
Copy link
Member

@sanojsubran sanojsubran left a comment

Choose a reason for hiding this comment

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

@Angith I have done one round of review. Kindly check my comments. We can discuss together.

// The main benefit of disabling is reducing the overall amount of data being collected and processed.

// See https://github.ibm.com/instana/technical-documentation/blob/master/tracing/specification/README.md#span-disabling for details
Disable map[string]bool
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: In my opinion, Disable variable name is not providing the complete context in this scenario as TracerOptions has options for multiple configuration items.

Tracer contains tracer-specific configuration used by all tracers. Key options include:

- **Disable**: A map of span categories to disable. Currently, only the "logging" category is supported. See [Disabling Log Spans](disabling_spans.md) for details.
- **DropAllLogs**: Turns log events on all spans into no-ops when set to true.
Copy link
Member

Choose a reason for hiding this comment

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

Query: How can the user set this, DropAllLogs? Is it a redundant one? May be we can discuss.

func (c spanCategory) String() string {
return string(c)
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: A comment would be nice since it is an exported function.

// If it is, it takes precedence over agent configuration
isConfigSet := len(sensor.options.Tracer.Disable) != 0
if isConfigSet {
r.logger.Info("Disable Tracing configuration is set either through in-code or INSTANA_TRACING_DISABLE environment variable," +
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Does it make sense to split this long log statement?

"os"
"strconv"
"strings"

"github.com/stretchr/testify/assert/yaml"
Copy link
Member

Choose a reason for hiding this comment

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

I am not positive about using a testing library in a source file.
@nithinputhenveettil What do you think?

@@ -0,0 +1,43 @@
// (c) Copyright IBM Corp. 2025
Copy link
Member

Choose a reason for hiding this comment

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

I think we should name the file for the component present, not for a feature.

@@ -0,0 +1,43 @@
// (c) Copyright IBM Corp. 2025

package instana
Copy link
Member

Choose a reason for hiding this comment

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

Query: In this implementation, do we need a separate file for spanCategory as such?

}

// registeredSpanMap maps span types to their categories
var registeredSpanMap map[RegisteredSpanType]spanCategory = map[RegisteredSpanType]spanCategory{
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Just check whether a function with(switch cases in the future) will be more suiting here. I think we won't be needing a map in that case.

if c == unknown {
return true
}
return !sensor.options.Tracer.Disable[c.String()]
Copy link
Member

Choose a reason for hiding this comment

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

I believe, false while accessing the map can imply either the value is not present or the map is not initialised. Just wanted to make sure that it is as per design. We can discuss.

return unknown
}

func (c spanCategory) Enabled() bool {
Copy link
Member

Choose a reason for hiding this comment

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

Query: Won't Disabled() is more meaningful?

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tekton_ci Add this label to start running Tekton pipelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants