providerconfighttp

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) providerconfig.SignalProcessor
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig"
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/log/global"
)

func main() {
	signalProcessor := providerconfighttp.New(
		providerconfighttp.WithCollectorEndpoint("0.0.0.0:9898"),
	)
	provider := providerconfig.New(providerconfig.WithApplicationName("example-app"),
		providerconfig.WithApplicationVersion("0.1.0"),
		providerconfig.WithSignalProcessor(signalProcessor),
	)
	// set providers
	otel.SetTracerProvider(provider.TraceProvider())
	otel.SetMeterProvider(provider.MetricProvider())
	global.SetLoggerProvider(provider.LogProvider())

	// shutdown all providers
	provider.ShutdownAll()
}

Types

type Option

type Option func(*httpConfig)

func WithBatchProcessorOptions

func WithBatchProcessorOptions(options ...log.BatchProcessorOption) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/sdk/log"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithBatchProcessorOptions(log.WithExportMaxBatchSize(512)),
	)
}

func WithCollectorEndpoint

func WithCollectorEndpoint(endpoint string) Option

WithCollectorEndpoint handled by providerconfig.New

Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithCollectorEndpoint("0.0.0.0:9898"),
		// or
		providerconfighttp.WithCollectorEndpoint("http://0.0.0.0:9898"),
	)
}

func WithInsecure added in v0.1.1

func WithInsecure() Option

WithInsecure appends the WithInsecure options for the trace, metric and log providers.

Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithCollectorEndpoint("0.0.0.0:9898"),
		providerconfighttp.WithInsecure(),
	)
}

func WithLogOptions

func WithLogOptions(options ...otlploghttp.Option) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithLogOptions(otlploghttp.WithCompression(otlploghttp.GzipCompression)),
	)
}

func WithMetricOptions

func WithMetricOptions(options ...otlpmetrichttp.Option) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithMetricOptions(otlpmetrichttp.WithCompression(otlpmetrichttp.GzipCompression)),
	)
}

func WithPeriodicReaderOptions

func WithPeriodicReaderOptions(options ...metric.PeriodicReaderOption) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/sdk/metric"
	"time"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithPeriodicReaderOptions(metric.WithInterval(5 * time.Second)),
	)
}

func WithSimpleProcessorOptions

func WithSimpleProcessorOptions(options ...log.SimpleProcessorOption) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithSimpleProcessorOptions( /*currently there are no options for the simpleProcessor*/ ),
	)
}

func WithSpanProcessorOptions

func WithSpanProcessorOptions(options ...trace.BatchSpanProcessorOption) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/sdk/trace"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithSpanProcessorOptions(trace.WithMaxExportBatchSize(512)),
	)
}

func WithTraceOptions

func WithTraceOptions(options ...otlptracehttp.Option) Option
Example
package main

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfighttp"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
)

func main() {
	providerconfighttp.New(
		providerconfighttp.WithTraceOptions(otlptracehttp.WithCompression(otlptracehttp.GzipCompression)),
	)
}

Jump to

Keyboard shortcuts

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