Skip to content

A Go library implementing the W3C Trace Context specification

License

Notifications You must be signed in to change notification settings

dschanoeh/w3c-trace-context

Repository files navigation

w3c-trace-context

License Go Reference

This Go library implements the W3C Trace Context Specification. It provides methods to parse existing Trace Context headers, to generate new headers or to mutate existing headers in accordance with the specification.

Usage

package main

import . "github.com/dschanoeh/w3c-trace-context"

func main() {
    // Start with empty headers or pass existing input headers
    headers := http.Header{}

    // Define a parent ID for the operation or leave empty for a randomly
    // generated one
    parentId := "myOperation" 
    // Optionally add a new tracestate member
    member := TraceStateMember {
        Key: "myKey",
        Value: "myValue",
    }
    newHeaders, tc, err := HandleTraceContext(&headers, parentId, &member, SamplingBehaviorPassThrough)

    // pass newHeaders to next systems
}

About

A Go library implementing the W3C Trace Context specification

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages