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

Improved http server request sampler logic #134

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

basvanbeek
Copy link
Member

@basvanbeek basvanbeek commented Jul 10, 2019

This is a breaking API change but brings the http server request sampler in line with the http client request sampler and allows for easy usage when treating the request sampler as black and/or white list. I don't like breaking changes even in 0.x.x version but the benefits outweigh the breakage inconvenience. This implements and closes #129 .

Example usage:

import (
    "net/http"
    zhttp "github.com/openzipkin/zipkin-go/middleware/http"
)

func MyRequestSampler(r *http.Request) *bool {
    switch r.URL.Path {
    case "/health":
        return zhttp.Discard() // not interested in tracing health checks
    case "/important/path":
        return zhttp.Sample() // trace this regardless of upstream decision
    }

    return nil // path didn't match so keep upstream decision as is
}

@jcchavezs
Copy link
Contributor

jcchavezs commented Jul 10, 2019 via email

@coveralls
Copy link

coveralls commented Jul 10, 2019

Coverage Status

Coverage increased (+11.3%) to 74.184% when pulling 8774349 on basvanbeek:http-server-request-sampler into 1277a5f on openzipkin:master.

@jcchavezs
Copy link
Contributor

@basvanbeek can we merge this?

@basvanbeek basvanbeek merged commit 4d0ee15 into openzipkin:master Jul 12, 2019
@basvanbeek basvanbeek deleted the http-server-request-sampler branch October 8, 2021 15:25
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

Successfully merging this pull request may close these issues.

Server side request sampler should take precedence if available
3 participants