stackdriver

package
v0.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Propagation added in v0.13.0

func Propagation() propagation.HTTPFormat
Example

Propagation exposes just the Stackdriver HTTP trace-context format, for use with the lower-level trace.Trace middleware when you want to combine it with other (non-default) settings.

package main

import (
	"github.com/moonrhythm/parapet"
	"github.com/moonrhythm/parapet/pkg/stackdriver"
	"github.com/moonrhythm/parapet/pkg/trace"
)

func main() {
	s := parapet.New()
	s.Use(&trace.Trace{
		Propagation:      stackdriver.Propagation(),
		IsPublicEndpoint: true,
	})
}

func Register added in v0.13.0

func Register(opt Options) trace.Exporter
Example

Register the OpenCensus Stackdriver (Google Cloud Trace) exporter once at startup, then mount the tracing middleware so every request is reported as a span. Register installs a global exporter; call it a single time. The returned trace.Exporter is also an exporter.Flusher you can flush on shutdown.

package main

import (
	"github.com/moonrhythm/parapet"
	"github.com/moonrhythm/parapet/pkg/stackdriver"
)

func main() {
	stackdriver.Register(stackdriver.Options{
		ProjectID:    "my-gcp-project",
		MetricPrefix: "parapet",
		Location:     "asia-southeast1",
	})

	s := parapet.New()
	s.Use(stackdriver.Trace())
	// s.Use(upstream.SingleHost("10.0.0.1:8080")) — the traced backend.
}

func Trace

func Trace() *trace.Trace

Trace creates new trace middleware with stackdriver propagation

Example

Trace returns the request-tracing middleware preconfigured with Stackdriver's trace-context propagation, so spans join an existing Google Cloud trace carried in the X-Cloud-Trace-Context header. The returned *trace.Trace can be tuned before wiring (e.g. mark the edge as a public endpoint so client-supplied span IDs start a fresh trace rather than being trusted as the parent).

package main

import (
	"github.com/moonrhythm/parapet"
	"github.com/moonrhythm/parapet/pkg/stackdriver"
)

func main() {
	t := stackdriver.Trace()
	t.IsPublicEndpoint = true

	s := parapet.New()
	s.Use(t)
}

Types

type Options added in v0.13.0

type Options = stackdriver.Options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL