Debian Codegraph @

internal/event/export/otel/options.go

raw symbols SCIP
1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package otel
6
7 import (
8 "time"
9 )
10
11 // Default configuration values.
12 const (
13 DefaultEndpoint = "http://localhost:4318"
14 DefaultServiceName = "unknown_service"
15 DefaultTimeout = 10 * time.Second
16 DefaultFlushPeriod = 2 * time.Second
17 )
18
19 // Option configures an OTelExporter.
20 type Option func(*Exporter)
21
22 // WithEndpoint sets the OTLP HTTP endpoint.
23 func WithEndpoint(endpoint string) Option {
24 return func(e *Exporter) {
25 e.endpoint = endpoint
26 }
27 }
28
29 // WithServiceName sets the service name for exported spans.
30 func WithServiceName(name string) Option {
31 return func(e *Exporter) {
32 e.serviceName = name
33 }
34 }
35
36 // WithTimeout sets the HTTP client timeout.
37 func WithTimeout(timeout time.Duration) Option {
38 return func(e *Exporter) {
39 e.client.Timeout = timeout
40 }
41 }
42
43 // WithFlushPeriod sets the interval for automatic background flushing.
44 func WithFlushPeriod(period time.Duration) Option {
45 return func(e *Exporter) {
46 e.flushPeriod = period
47 }
48 }
49
50 // WithServiceVersion sets the service version for exported telemetry.
51 func WithServiceVersion(version string) Option {
52 return func(e *Exporter) {
53 e.serviceVersion = version
54 }
55 }