Skip to content
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

Add optoinal deep tracing to request #42

Open
sam-at-luther opened this issue Sep 16, 2024 · 1 comment
Open

Add optoinal deep tracing to request #42

sam-at-luther opened this issue Sep 16, 2024 · 1 comment
Assignees

Comments

@sam-at-luther
Copy link
Member

No description provided.

@sam-at-luther sam-at-luther self-assigned this Sep 16, 2024
@sam-at-luther
Copy link
Member Author

Suggestion to add a helper function to set deepTracing flag on trace baggage which is propagated across the stack:

package trace

import (
    "context"
    "fmt"
    "go.opentelemetry.io/otel/baggage"
    "go.opentelemetry.io/otel/label"
)

// AddDeepTracingToContext adds the deepTracing flag to the context as baggage.
func AddDeepTracingToContext(ctx context.Context, enableDeepTracing bool) (context.Context, error) {
    if enableDeepTracing {
        member, err := label.New("deepTracing", "true")
        if err != nil {
            return ctx, fmt.Errorf("failed to create baggage member: %w", err)
        }
        return baggage.ContextWithValues(ctx, member), nil
    }
    return ctx, nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant