Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Trace should Ignore Options method and specific paths #251

Open
Talento90 opened this issue Mar 22, 2019 · 1 comment
Open

Trace should Ignore Options method and specific paths #251

Talento90 opened this issue Mar 22, 2019 · 1 comment

Comments

@Talento90
Copy link

First of all thanks for this amazing project. I am using tracing to stackdriver and I would like to know How can I ignore http OPTION method and also some specific paths like /swagger or /.

For your info I am using ochttp to instrument my http server.

	return &http.Server{
		Handler:      &ochttp.Handler{Handler: router },
	}
@Talento90
Copy link
Author

Talento90 commented Mar 25, 2019

It seems that using GetStartOptions it ignores the OPTIONS method but not the "/" path :(

Handler: &ochttp.Handler{
	Handler: router,
	GetStartOptions: func(r *http.Request) trace.StartOptions {
		if r.Method == http.MethodOptions || r.URL.Path == "/" {
			return trace.StartOptions{
				Sampler:  trace.NeverSample(),
				SpanKind: trace.SpanKindServer,
			}
		}

		return trace.StartOptions{
			Sampler:  trace.AlwaysSample(),
			SpanKind: trace.SpanKindServer,
		}
	},
},

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

No branches or pull requests

1 participant