providerconfiggrpc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 13 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/providerconfiggrpc"
	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/log/global"
)

func main() {
	signalProcessor := providerconfiggrpc.New(
		providerconfiggrpc.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()
}
Output:

Types

type Option

type Option func(*grpcConfig)

func WithBatchProcessorOptions

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

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

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithBatchProcessorOptions(log.WithExportMaxBatchSize(512)),
	)
}
Output:

func WithCollectorEndpoint

func WithCollectorEndpoint(url string, port int) Option

WithCollectorEndpoint handled by providerconfig.New Has no effect when WithGRPCConn is set for any of the Options

Example
package main

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

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithCollectorEndpoint("0.0.0.0", 9898),
	)
}
Output:

func WithLogOptions

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

import (
	"github.com/vincentfree/opentelemetry/providerconfig/providerconfiggrpc"
	"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc"
	"time"
)

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithLogOptions(
			otlploggrpc.WithCompressor("gzip"),
			otlploggrpc.WithTimeout(5*time.Second),
		),
	)
}
Output:

func WithMetricOptions

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

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

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithMetricOptions(otlpmetricgrpc.WithCompressor("gzip")),
	)
}
Output:

func WithPeriodicReaderOptions

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

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

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

func WithSimpleProcessorOptions

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

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

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

func WithSpanProcessorOptions

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

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

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithSpanProcessorOptions(trace.WithMaxExportBatchSize(512)),
	)
}
Output:

func WithTraceOptions

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

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

func main() {
	providerconfiggrpc.New(
		providerconfiggrpc.WithTraceOptions(otlptracegrpc.WithCompressor("gzip")),
	)
}
Output:

Jump to

Keyboard shortcuts

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