### Start Docker Compose Services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/example Use this command to bring up the necessary services for the example. Ensure Docker Compose is installed. ```bash docker-compose up --detach mux-server mux-client ``` -------------------------------- ### Start go-restful Server and Client Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/example Use this command to bring up the go-restful server and client services for the example. Ensure Docker Compose is installed. ```bash docker-compose up --detach go-restful-server go-restful-client ``` -------------------------------- ### Start go-kit Server and Client Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit/example Starts the kit-server and kit-client services using docker-compose. Ensure docker-compose is installed before running. ```bash docker-compose up --detach kit-server kit-client ``` -------------------------------- ### Start Zipkin Services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/zipkin Bring up the zipkin-collector and zipkin-client services to send an example trace. Ensure docker-compose is installed. ```bash docker-compose up --detach zipkin-collector zipkin-client ``` -------------------------------- ### Start Gin-Gonic Server and Client Services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/gin-gonic/gin/example Use this command to bring up the necessary Docker Compose services for the Gin-Gonic instrumentation example. Ensure Docker Compose is installed. ```bash docker-compose up --detach gin-server gin-client ``` -------------------------------- ### Start Echo Server and Client Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho/example Use docker-compose to bring up the echo-server and echo-client services for the example. ```bash docker-compose up --detach echo-server echo-client ``` -------------------------------- ### Start Kafka and ZooKeeper Services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/example Use docker-compose to bring up the Kafka and ZooKeeper services for the example. ```bash docker-compose up -d zoo kafka ``` -------------------------------- ### Start AWS Lambda Example with Docker Compose Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/example Use this command to bring up the project's services in detached mode. ```bash docker-compose up --detach ``` -------------------------------- ### Running the Integration Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/example Instructions to set up and run the gocql integration example. Requires Docker Compose for Cassandra and Zipkin. ```bash cd docker-compose up go run . ``` -------------------------------- ### Install AWS Lambda Resource Detector Source: https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/aws/lambda Install the AWS Lambda resource detector package using go get. ```bash go get -u go.opentelemetry.io/contrib/detectors/aws/lambda ``` -------------------------------- ### Start Docker Compose Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example Bring up the project environment using docker-compose. Ensure docker-compose is installed and AWS credentials are configured. ```bash docker-compose up --detach ``` -------------------------------- ### Run Integration Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/example Instructions to run the integration example. Requires Docker Compose for Cassandra and Zipkin, and then running the Go program. Spans and metrics can be viewed at specified local addresses. ```bash cd docker-compose up go run . ``` -------------------------------- ### Get Start Time from Context Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Retrieves a start time from the context. Returns a zero time and false if no start time is found. ```go func StartTimeFromContext(ctx context.Context) time.Time ``` -------------------------------- ### ExtractFromParent Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/propagators/envcar Shows how to extract trace information from environment variables into the context when a program is started by a parent process. ```go Output: Trace ID: 0102030405060708090a0b0c0d0e0f10 Span ID: 0102030405060708 Sampled: true ``` -------------------------------- ### Context with Start Time Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Returns a new context with a specified start time. This time will be used for metrics and traces. Only one start time can be in the context; subsequent calls override previous ones. ```go func ContextWithStartTime(parent context.Context, start time.Time) context.Context ``` -------------------------------- ### Instrgen Example with Wildcard Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen This example demonstrates instrumenting all packages within the specified testdata path using the './...' wildcard. ```bash ./instrgen --inject ./testdata/basic ./... ``` -------------------------------- ### Deploy OpenTelemetry Collector, Jaeger, and Prometheus Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/otel-collector Use this command to start the necessary services for the example. Ensure Docker Compose V2 is installed. ```bash docker compose up -d ``` -------------------------------- ### Start Host Metrics Reporting Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/host Initializes the reporting of host metrics using the supplied configuration options. This function starts the collection and export of host-related metrics. ```go func Start(opts ...Option) error ``` -------------------------------- ### Stop Integration Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/example Instructions to stop and clean up resources after running the integration example. This involves stopping the Go program and then stopping the Docker Compose services. ```bash ctrl+c docker-compose down ``` -------------------------------- ### Datadog Exporter Example Output Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/datadog Example of the metric format sent to Datadog. ```go mycounter:151|c|#env:dev,l:1,service.name:ExampleExporter,telemetry.sdk.language:go,telemetry.sdk.name:opentelemetry,telemetry.sdk.version:1.4.0 ``` -------------------------------- ### Install Cortex Exporter Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex Installs the Cortex exporter and sets up a new push controller. Requires a Config struct and returns the controller and an error. Defer stopping the controller. ```go go get -u go.opentelemetry.io/contrib/exporters/metric/cortex ``` ```go // Create a Config struct named `config`. controller, err := cortex.InstallNewPipeline(config) if err != nil { return err } deferr controller.Stop(context.Background()) // Make instruments and record data using `global.MeterProvider`. ``` -------------------------------- ### Option Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/runtime Supports configuring optional settings for runtime metrics. This is an interface used with the `Start` function. ```APIDOC ## Option ### Description Option supports configuring optional settings for runtime metrics. This is an interface used with the `Start` function. ### Methods #### WithMeterProvider ##### Description Sets the Metric implementation to use for reporting. If this option is not used, the global `metric.MeterProvider` will be used. `provider` must be non-nil. ##### Signature `func WithMeterProvider(provider metric.MeterProvider) Option` #### WithMinimumReadMemStatsInterval ##### Description Sets a minimum interval between calls to `runtime.ReadMemStats()`, which is a relatively expensive call to make frequently. This setting is ignored when `d` is negative. ##### Signature `func WithMinimumReadMemStatsInterval(d time.Duration) Option` ``` -------------------------------- ### Start Kafka Consumer Service Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/example Use docker-compose to start the kafka-consumer service to receive messages from Kafka. ```bash docker-compose up kafka-consumer ``` -------------------------------- ### Run Docker Compose Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex/example Starts the Docker services for the Cortex exporter example in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### Example Output for Detector Source: https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/autodetect This example shows the expected output format when the Detector function is used to merge resources. ```text host.name my.key telemetry.sdk.language telemetry.sdk.name telemetry.sdk.version ``` -------------------------------- ### ContextWithStartTime Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp ContextWithStartTime returns a new context with the provided start time. The start time will be used for metrics and traces emitted by the instrumentation. ```APIDOC ## func ContextWithStartTime ### Description Injects a start time into the context. This start time will be used for metrics and traces emitted by the otelhttp instrumentation. Only one start time can be present in the context; subsequent calls will override previous ones. ### Signature ```go func ContextWithStartTime(parent context.Context, start time.Time) context.Context ``` ### Parameters * `parent` (context.Context) - The parent context. * `start` (time.Time) - The start time to inject into the context. ``` -------------------------------- ### Start Kafka Producer Service Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/example Use docker-compose to start the kafka-producer service to send messages to Kafka. ```bash docker-compose up kafka-producer ``` -------------------------------- ### Severitier Example (Environment) Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev Demonstrates using a Severitier that reads the minimum severity level from an environment variable. ```go Output: false true ``` -------------------------------- ### ChildProcess Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/propagators/envcar Demonstrates injecting a trace into a command to be run in a child process using the envcar Carrier. ```go Output: 00-0102030405060708090a0b0c0d0e0f10-0102030405060708-01 ``` -------------------------------- ### Install xrayconfig Package Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig Install the xrayconfig package for AWS Lambda instrumentation with AWS X-Ray. ```bash go get -u go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig ``` -------------------------------- ### Configure Span Start Options Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin Use WithSpanStartOptions to apply additional trace.SpanStartOptions to each new span created by the middleware. ```go func WithSpanStartOptions(opts ...oteltrace.SpanStartOption) Option ``` -------------------------------- ### Install otellambda Package Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda Use this command to add the otellambda instrumentation package to your Go project. ```bash go get -u go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda ``` -------------------------------- ### Run the OpenTelemetry Example Application Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/otel-collector Execute the main Go program to simulate an application and generate telemetry data. Requires Go version 1.13 or higher. ```bash go run main.go ``` -------------------------------- ### StartTimeFromContext Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Retrieves a start time from the provided context. If no start time is found, a zero time and false are returned. ```APIDOC ## func StartTimeFromContext ### Description StartTimeFromContext retrieves a time.Time from the provided context if one is available. If no start time was found in the provided context, a new, zero start time is returned and the second return value is false. ### Signature ```go func StartTimeFromContext(ctx context.Context) time.Time ``` ``` -------------------------------- ### Install OpenTelemetry Pipeline with Cortex Exporter Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex Installs a push Controller's MeterProvider globally, registering it with the OpenTelemetry SDK. Use this function to set up the default pipeline for metric collection and export. ```go func InstallNewPipeline(config Config, options ...controller.Option) (*controller.Controller, error) ``` -------------------------------- ### OnStart SpanProcessor Source: https://pkg.go.dev/go.opentelemetry.io/contrib/zpages Adds a span as active and reports it with zpages when a span starts. ```go func (ssm *SpanProcessor) OnStart(_ context.Context, span sdktrace.ReadWriteSpan) ``` -------------------------------- ### String Method Examples Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev Illustrates the output of the Severity.String() method for various severity levels and offsets. ```go SeverityWarn1.String() => "WARN" (SeverityInfo1+2).String() => "INFO3" (SeverityFatal4+2).String() => "FATAL+6" (SeverityTrace1-3).String() => "TRACE-3" ``` -------------------------------- ### Install DogStatsD Pipeline Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/dogstatsd Installs a new DogStatsD export pipeline and registers it globally. Typically called with a configuration object. ```go func InstallNewPipeline(config Config) (*controller.Controller, error) ``` ```go pipeline, err := dogstatsd.InstallNewPipeline(dogstatsd.Config{ // ... configuration ... }) if err != nil { // ... handle error ... } defer pipeline.Stop() // ... use pipeline ... ``` -------------------------------- ### Start Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/runtime Initializes reporting of runtime metrics using the supplied configuration. It can emit various runtime statistics and supports deprecated metrics if the relevant environment variable is set. ```APIDOC ## Start ### Description Initializes reporting of runtime metrics using the supplied configuration. For goroutine scheduling metrics, additionally see NewProducer. Metrics emitted by Start includes: - `go.memory.used` (Bytes): Memory used by the Go runtime. - `go.memory.limit` (Bytes): Go runtime memory limit configured by the user, if a limit exists. - `go.memory.allocated` (Bytes): Memory allocated to the heap by the application. - `go.memory.allocations` ({allocation}): Count of allocations to the heap by the application. - `go.memory.gc.goal` (Bytes): Heap size target for the end of the GC cycle. - `go.goroutine.count` ({goroutine}): Count of live goroutines. - `go.processor.limit` ({thread}): The number of OS threads that can execute user-level Go code simultaneously. - `go.config.gogc` (%): Heap size target percentage configured by the user, otherwise 100. When the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable is set to true, the following deprecated metrics are produced: - `runtime.go.cgo.calls` (-): Number of cgo calls made by the current process - `runtime.go.gc.count` (-): Number of completed garbage collection cycles - `runtime.go.gc.pause_ns` (ns): Amount of nanoseconds in GC stop-the-world pauses - `runtime.go.gc.pause_total_ns` (ns): Cumulative nanoseconds in GC stop-the-world pauses since the program started - `runtime.go.goroutines` (-): Number of goroutines that currently exist - `runtime.go.lookups` (-): Number of pointer lookups performed by the runtime - `runtime.go.mem.heap_alloc` (bytes): Bytes of allocated heap objects - `runtime.go.mem.heap_idle` (bytes): Bytes in idle (unused) spans - `runtime.go.mem.heap_inuse` (bytes): Bytes in in-use spans - `runtime.go.mem.heap_objects` (-): Number of allocated heap objects - `runtime.go.mem.heap_released` (bytes): Bytes of idle spans whose physical memory has been returned to the OS - `runtime.go.mem.heap_sys` (bytes): Bytes of heap memory obtained from the OS - `runtime.go.mem.live_objects` (-): Number of live objects is the number of cumulative Mallocs - Frees - `runtime.uptime` (ms): Milliseconds since application was initialized. ### Method `func Start(opts ...Option) error` ### Parameters #### Options - `opts ...Option`: A variadic list of `Option` to configure the runtime metrics reporting. ``` -------------------------------- ### Configure Handler with Additional Span Start Options Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http Use WithSpanOptions to apply extra trace.StartOptions to each new span. These options are merged with any default options. ```go func WithSpanOptions(opts ...trace.StartOption) Option ``` -------------------------------- ### AWS Lambda Instrumentation with Options Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda An example demonstrating how to use otellambda with various configuration options, including a custom TracerProvider, Flusher, EventToCarrier, and TraceAttributeFn. This allows for advanced customization of the tracing behavior. ```go var someHeaderKey = "Key" // used by propagator and EventToCarrier function to identify trace header type mockHTTPRequest struct { Headers map[string][]string Body string } func mockEventToCarrier(eventJSON []byte) propagation.TextMapCarrier{ var request mockHTTPRequest _ = json.unmarshal(eventJSON, &request) return propagation.HeaderCarrier{someHeaderKey: []string{request.Headers[someHeaderKey]}} } func mockTraceAttributeFn(eventJSON []byte) []attribute.KeyValue { var request mockHTTPRequest _ = json.unmarshal(eventJSON, &request) return []attribute.KeyValue{attribute.String("mock.request.type", reflect.TypeOf(request).String())} } type mockPropagator struct{} // Extract - read from `someHeaderKey` // Inject // Fields func HandleRequest(ctx context.Context, request mockHTTPRequest) error { return fmt.Sprintf("Hello %s!", request.Body ), nil } func main() { exp, _ := stdouttrace.New() tp := sdktrace.NewTracerProvider( sdktrace.WithBatcher(exp)) lambda.Start(otellambda.InstrumentHandler(HandleRequest, otellambda.WithTracerProvider(tp), otellambda.WithFlusher(tp), otellambda.WithTraceAttributeFn(mockTraceAttributeFn), otellambda.WithEventToCarrier(mockEventToCarrier), otellambda.WithPropagator(mockPropagator{}))) } ``` -------------------------------- ### Setup SDK and Propagators for Span Recording Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/passthrough This configuration propagates context and creates new spans, potentially recorded by the SDK. It involves setting up both a TracerProvider and TextMapPropagators. ```go // Setup SDK exp, _ := stdout.New(stdout.WithPrettyPrint()) tp = sdktrace.NewTracerProvider( sdktrace.WithBatcher(exp), ) otel.SetTracerProvider(tp) // Setup Propagators otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) ``` -------------------------------- ### Start Runtime Metrics Collection Source: https://pkg.go.dev/go.opentelemetry.io/contrib/plugins/runtime Begins regular background polling of Go runtime metrics. Returns an error if any issues occur during startup. ```Go func (r *Runtime) Start() error ``` -------------------------------- ### Manual AWS Resource Cleanup Script Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/example Execute this script if the example is terminated early to ensure all created AWS resources are cleaned up. ```bash ./manualAWSCleanup.sh ``` -------------------------------- ### Create New Export Pipeline with Cortex Exporter Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex Sets up a complete export pipeline including a push Controller and Exporter for Cortex. This is a convenient way to initialize a fully functional metric export setup. ```go func NewExportPipeline(config Config, options ...controller.Option) (*controller.Controller, error) ``` -------------------------------- ### Start Runtime Metrics Reporting Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/runtime Initializes the reporting of runtime metrics. Use WithMeterProvider to specify a custom meter provider or WithMinimumReadMemStatsInterval to adjust the interval for ReadMemStats calls. ```go func Start(opts ...Option) error ``` -------------------------------- ### Shut down the example services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/otel-collector Clean up the running Docker containers for the OpenTelemetry Collector, Jaeger, and Prometheus. ```bash docker compose down ``` -------------------------------- ### InstallNewPipeline Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/dogstatsd Installs a new export pipeline globally using the provided configuration. This function is typically called at the beginning of an application to set up metrics export. ```APIDOC ## InstallNewPipeline ### Description Installs a NewExportPipeline and registers it globally. Typically called as: ``` pipeline, err := dogstatsd.InstallNewPipeline(dogstatsd.Config{...}) if err != nil { ... } defer pipeline.Stop() ... ``` ### Function Signature ``` func InstallNewPipeline(config Config) (*controller.Controller, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **controller.Controller**: A controller for managing the export pipeline. - **error**: An error if the pipeline could not be installed. #### Response Example None ``` -------------------------------- ### WithOpenTelemetryConfiguration Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/config/v0.2.0 Creates a ConfigurationOption to set the OpenTelemetryConfiguration used to produce the SDK. This allows for detailed SDK setup. ```go func WithOpenTelemetryConfiguration(cfg OpenTelemetryConfiguration) ConfigurationOption ``` -------------------------------- ### Setup Propagators Only for Passthrough Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/passthrough Use this configuration to propagate context without recording spans. Ensure only TextMapPropagators are set, and no TracerProvider is installed. ```go // Setup Propagators only otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) ``` -------------------------------- ### Start Host Metrics Reporting Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/host Initializes the reporting of host metrics. This function can be configured with various options to customize its behavior, such as specifying a MeterProvider. ```APIDOC ## func Start ### Description Start initializes reporting of host metrics using the supplied config. ### Signature ```go func Start(opts ...Option) error ``` ### Parameters * `opts` (...Option) - Optional configuration settings for starting host metrics reporting. ``` -------------------------------- ### Middleware Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux Middleware sets up a handler to start tracing the incoming requests. The service parameter should describe the name of the (virtual) server handling the request. ```APIDOC ## Middleware ### Description Middleware sets up a handler to start tracing the incoming requests. The service parameter should describe the name of the (virtual) server handling the request. ### Function Signature ```go func Middleware(service string, opts ...Option) mux.MiddlewareFunc ``` ### Parameters - **service** (string) - The name of the (virtual) server handling the request. - **opts** (...Option) - Optional configuration options for the middleware. ``` -------------------------------- ### View Server Span Logs Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit/example Displays the logs for the kit-server service, which includes the generated span information. This command should be run after starting the services. ```bash docker-compose logs kit-server ``` -------------------------------- ### Create and Load Cortex Configuration from YAML Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex/utils Demonstrates how to create a custom HTTP client and use it to load a Cortex configuration from a YAML file, specifying search paths and the client. This is useful for customizing exporter settings. ```go // Create a custom HTTP client. client := http.DefaultClient // Search for a YAML file named config.yml in "." and "./configs" and use it to create a // Config struct with the provided HTTP client. config, err := NewConfig("config.yml", WithFilepath("./configs"), WithClient(client)) if err != nil { // Handle error } // Use newly created Config struct! ``` -------------------------------- ### Get Operation Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/bradfitz/gomemcache Invokes the memcache Get operation and traces its execution. Errors during the operation will be recorded in the trace span. ```go func (c *Client) Get(key string) (*memcache.Item, error) ``` -------------------------------- ### Fetch Sampling Strategy with curl Source: https://pkg.go.dev/go.opentelemetry.io/contrib/samplers/jaegerremote Examples of how to fetch sampling strategies from a Jaeger sampling server using curl. Replace 'foo' and 'myService' with your actual service names. ```bash curl 'localhost:5778/sampling?service=foo' ``` ```bash curl 'localhost:5778/sampling?service=myService' ``` -------------------------------- ### MeterProvider Configuration Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf Configures a MeterProvider with exemplar filters, readers, and views. ```go type MeterProvider struct { // Configure the exemplar filter. // Values include: // * always_off: ExemplarFilter which makes no measurements eligible for being an // Exemplar. // * always_on: ExemplarFilter which makes all measurements eligible for being an // Exemplar. // * trace_based: ExemplarFilter which makes measurements recorded in the context // of a sampled parent span eligible for being an Exemplar. // If omitted, trace_based is used. // ExemplarFilter *ExemplarFilter `json:"exemplar_filter,omitempty,omitzero" yaml:"exemplar_filter,omitempty" mapstructure:"exemplar_filter,omitempty"` // Configure metric readers. // Property is required and must be non-null. // Readers []MetricReader `json:"readers" yaml:"readers" mapstructure:"readers"` // Configure views. // Each view has a selector which determines the instrument(s) it applies to, and // a configuration for the resulting stream(s). // If omitted, no views are registered. // Views []View `json:"views,omitempty,omitzero" yaml:"views,omitempty" mapstructure:"views,omitempty"` } ``` -------------------------------- ### Get EKS Resource Detector Version Source: https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/aws/eks Version is the current release version of the EKS resource detector. Use this function to get the current release version. ```go func Version() string ``` -------------------------------- ### SDK Initialization and Accessors Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf Demonstrates how to create a new OpenTelemetry SDK instance and access its core providers (TracerProvider, MeterProvider, LoggerProvider) and propagator. It also shows how to shut down the SDK gracefully. ```APIDOC ## SDK ### Description Provides methods to initialize and manage the OpenTelemetry SDK. ### Functions * **NewSDK(opts ...ConfigurationOption) (SDK, error)** * Description: Creates a new SDK instance with the provided configuration options. * Returns: An SDK instance and an error if initialization fails. * **(*SDK) LoggerProvider() log.LoggerProvider** * Description: Returns the LoggerProvider associated with this SDK. * **(*SDK) MeterProvider() metric.MeterProvider** * Description: Returns the MeterProvider associated with this SDK. * **(*SDK) Propagator() propagation.TextMapPropagator** * Description: Returns the TextMapPropagator associated with this SDK. * **(*SDK) Shutdown(ctx context.Context) error** * Description: Shuts down the SDK, flushing any pending data and releasing resources. * Parameters: * **ctx** (context.Context) - The context for the shutdown operation. * Returns: An error if the shutdown process fails. * **(*SDK) TracerProvider() trace.TracerProvider** * Description: Returns the TracerProvider associated with this SDK. ``` -------------------------------- ### Go Runtime Metrics Overview Source: https://pkg.go.dev/go.opentelemetry.io/contrib/plugins/runtime Lists the available Go runtime metrics provided by the package, including their names, units, and descriptions. ```Go runtime.go.cgo.calls - Number of cgo calls made by the current process runtime.go.gc.count - Number of completed garbage collection cycles runtime.go.gc.pause_ns (ns) Amount of nanoseconds in GC stop-the-world pauses runtime.go.gc.pause_total_ns (ns) Cumulative nanoseconds in GC stop-the-world pauses since the program started runtime.go.goroutines - Number of goroutines that currently exist runtime.go.lookups - Number of pointer lookups performed by the runtime runtime.go.mem.heap_alloc (bytes) Bytes of allocated heap objects runtime.go.mem.heap_idle (bytes) Bytes in idle (unused) spans runtime.go.mem.heap_inuse (bytes) Bytes in in-use spans runtime.go.mem.heap_objects - Number of allocated heap objects runtime.go.mem.heap_released (bytes) Bytes of idle spans whose physical memory has been returned to the OS runtime.go.mem.heap_sys (bytes) Bytes of heap memory obtained from the OS runtime.go.mem.live_objects - Number of live objects is the number of cumulative Mallocs - Frees runtime.uptime (ms) Milliseconds since application was initialized ``` -------------------------------- ### LogSink Init Method Source: https://pkg.go.dev/go.opentelemetry.io/contrib/bridges/otellogr The Init method receives optional runtime information from the logr library, though this implementation does not utilize it. ```go func (*LogSink) Init(logr.RuntimeInfo) ``` -------------------------------- ### GetPkgNameFromDefsTable Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/lib Gets the package name from the definitions table. ```APIDOC ## GetPkgNameFromDefsTable ### Description GetPkgNameFromDefsTable gets package name from uses table. ### Signature ```go func GetPkgNameFromDefsTable(pkg *packages.Package, ident *ast.Ident) string ``` ``` -------------------------------- ### Get Attributes from Labeler Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Returns a copy of the attributes that have been added to the Labeler. ```go func (l *Labeler) Get() []attribute.KeyValue ``` -------------------------------- ### Labeler.Get Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Get returns the list of attributes currently associated with the Labeler. ```APIDOC ## func (l *Labeler) Get ### Description Retrieves all key-value attributes currently associated with the Labeler. These attributes are intended to be used with metrics emitted by the otelhttp instrumentation. ### Signature ```go func (l *Labeler) Get() []attribute.KeyValue ``` ### Returns * `[]attribute.KeyValue` - A slice of attributes associated with the Labeler. ``` -------------------------------- ### Instrument Lambda Handler with lambda.Start Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda Use otellambda.InstrumentHandler to wrap your Lambda function when using the lambda.Start entrypoint. ```go lambda.Start(otellambda.InstrumentHandler()) ``` -------------------------------- ### GetPkgNameFromUsesTable Function Signature Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/lib Gets the package name from the uses table. ```go func GetPkgNameFromUsesTable(pkg *packages.Package, ident *ast.Ident) string ``` -------------------------------- ### GetPkgNameFromDefsTable Function Signature Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/lib Gets the package name from the definitions table. ```go func GetPkgNameFromDefsTable(pkg *packages.Package, ident *ast.Ident) string ``` -------------------------------- ### Stop Zipkin Services Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/zipkin Shut down the zipkin-collector and zipkin-client services when you are finished with the example. ```bash docker-compose down ``` -------------------------------- ### NewSDK Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/config/v0.2.0 Creates SDK providers based on the provided configuration options. ```go func NewSDK(opts ...ConfigurationOption) (SDK, error) ``` -------------------------------- ### Get Template Name Attribute Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego Returns the template name as a KeyValue pair. ```go func Template(name string) attribute.KeyValue ``` -------------------------------- ### ProducerMessageCarrier Get Method Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama Retrieves a single value for a given key from the ProducerMessageCarrier. ```go func (c ProducerMessageCarrier) Get(key string) string ``` -------------------------------- ### ConsumerMessageCarrier Get Method Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama Retrieves a single value for a given key from the ConsumerMessageCarrier. ```go func (c ConsumerMessageCarrier) Get(key string) string ``` -------------------------------- ### Get otellogrus Version Source: https://pkg.go.dev/go.opentelemetry.io/contrib/bridges/otellogrus Retrieves the current release version of the otellogrus bridge. ```go const Version = "0.19.0" ``` -------------------------------- ### Create Hetzner Resource Detector with Options Source: https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/hetzner Initializes a new Hetzner resource detector. Options can be used to configure attribute filtering. ```go func NewResourceDetector(opts ...Option) *ResourceDetector ``` -------------------------------- ### Get otellogrus Levels Source: https://pkg.go.dev/go.opentelemetry.io/contrib/bridges/otellogrus Returns the list of log levels that will trigger the otellogrus Hook. ```go func (h *Hook) Levels() []logrus.Level ``` -------------------------------- ### NewSDK Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf/x Creates SDK providers based on the configuration model. It checks the local environment and uses the file set in the variable `OTEL_EXPERIMENTAL_CONFIG_FILE` to configure the SDK automatically. Any file defined by `OTEL_EXPERIMENTAL_CONFIG_FILE` will supersede all files passed with `WithOpenTelemetryConfiguration`. ```APIDOC ## NewSDK ### Description Creates SDK providers based on the configuration model. It checks the local environment and uses the file set in the variable `OTEL_EXPERIMENTAL_CONFIG_FILE` to configure the SDK automatically. Any file defined by `OTEL_EXPERIMENTAL_CONFIG_FILE` will supersede all files passed with `WithOpenTelemetryConfiguration`. ### Signature ```go func NewSDK(opts ...ConfigurationOption) (SDK, error) ``` ### Parameters #### Variadic Parameters - **opts** (*ConfigurationOption) - Options to configure the SDK. ``` -------------------------------- ### OnEnd Implementation for BaggageTrace SpanProcessor Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/baggage/baggagetrace The OnEnd method is a no-op for this processor, as it only acts on span start. ```go func (processor SpanProcessor) OnEnd(s trace.ReadOnlySpan) ``` -------------------------------- ### Metric Export Success/Failure Example Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex Illustrates how cumulative metrics are preserved even if some exports fail. ```text SUCCESS FAIL FAIL SUCCESS SUCCESS 1 2 3 4 5 ``` -------------------------------- ### Kafka Topic Constant Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/example Defines the Kafka topic name used for the Sarama instrumentation example. ```go const ( KafkaTopic = "sarama-instrumentation-example" ) ``` -------------------------------- ### Shut Down Docker Compose Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex/example Stops and removes the Docker services used in the Cortex exporter example. ```bash docker-compose down ``` -------------------------------- ### Create New HTTP Client Trace Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/httptrace Initializes a new httptrace.ClientTrace for instrumenting HTTP client requests. ```go func NewClientTrace(ctx context.Context) *httptrace.ClientTrace ``` -------------------------------- ### HelloService_SayHelloBidiStreamServer Interface Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/example/api Server-side interface for bidirectional streaming in SayHelloBidiStream. ```go type HelloService_SayHelloBidiStreamServer interface { Send(*HelloResponse) error Recv() (*HelloRequest, error) grpc.ServerStream } ``` -------------------------------- ### WithContext Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/config/v0.3.0 Creates a ConfigurationOption to set the context.Context for the SDK. ```go func WithContext(ctx context.Context) ConfigurationOption ``` -------------------------------- ### Get String Representation Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev Returns a string representation of the SeverityVar. This method is available from v0.11.0 onwards. ```go func (v *SeverityVar) String() string ``` -------------------------------- ### Get OT Header Keys Source: https://pkg.go.dev/go.opentelemetry.io/contrib/propagators/ot Returns the OT header keys that are set by the Inject function. ```go func (OT) Fields() []string ``` -------------------------------- ### Create Cortex Exporter Config Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/cortex Demonstrates two methods for creating a Cortex exporter configuration: using the utils module to load from a YAML file or creating the struct manually. The Validate() method is crucial for manual configuration. ```go // (Option 1) Create Config struct using utils module. config, err := utils.NewConfig("config.yml") if err != nil { return err } // (Option 2) Create Config struct manually. configTwo := cortex.Config { Endpoint: "http://localhost:9009/api/prom/push", RemoteTimeout: 30 * time.Second, PushInterval: 5 * time.Second, Headers: map[string]string{ "test": "header", }, } // Validate() should be called when creating the Config struct manually. err = config.Validate() if err != nil { return err } ``` -------------------------------- ### Get DogStatsD Attribute Encoder ID Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/dogstatsd Returns the unique identifier for the DogStatsD attribute encoder. ```go func (*AttributeEncoder) ID() attribute.EncoderID ``` -------------------------------- ### func Init() (*sdktrace.TracerProvider, error) Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/example/config Initializes the OpenTelemetry exporter and trace provider. This function is crucial for setting up tracing in your gRPC services. ```APIDOC ## func Init() ### Description Initializes an OpenTelemetry exporter and trace provider. This function is essential for setting up tracing within your application. ### Signature ```go func Init() (*sdktrace.TracerProvider, error) ``` ### Returns - `*sdktrace.TracerProvider`: A configured trace provider instance. - `error`: An error if the initialization fails. ``` -------------------------------- ### PathPrefix Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/filters PathPrefix returns a Filter that returns true if the request's path starts with the provided string. ```APIDOC ## PathPrefix ### Description PathPrefix returns a Filter that returns true if the request's path starts with the provided string. ### Signature ```go func PathPrefix(p string) otelhttp.Filter ``` ``` -------------------------------- ### Entry Point Instrumentation Call Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen Add this call in your main function to enable automatic instrumentation. ```go func main() { rtlib.AutotelEntryPoint() ``` -------------------------------- ### Configure otellambda with X-Ray Recommended Options Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig Integrate xrayconfig's recommended options into the otellambda InstrumentHandler call to enable AWS X-Ray tracing. ```go // Add import import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig" // add options to InstrumentHandler call func main() { lambda.Start(otellambda.InstrumentHandler(HandleRequest, xrayconfig.WithRecommendedOptions()...)) } ``` -------------------------------- ### PackageAnalysis Execute Method Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/lib The main entry point for the analysis process, executing a specified analysis pass. ```go func (analysis *PackageAnalysis) Execute(pass FileAnalysisPass, fileSuffix string) ([]*ast.File, error) ``` -------------------------------- ### GetMostInnerAstIdent Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/lib Takes the most inner identifier used for a function call. For example, in `a.b.foo()`, `b` will be the most inner identifier. ```APIDOC ## GetMostInnerAstIdent ### Description GetMostInnerAstIdent takes most inner identifier used for function call. For a.b.foo(), `b` will be the most inner identifier. ### Signature ```go func GetMostInnerAstIdent(inSel *ast.SelectorExpr) *ast.Ident ``` ``` -------------------------------- ### WithContext Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/config/v0.2.0 Creates a ConfigurationOption to set the context.Context for the SDK. Use this to pass request-scoped values, cancellation signals, and deadlines. ```go func WithContext(ctx context.Context) ConfigurationOption ``` -------------------------------- ### Define Kafka Topic Constant Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama/example Defines the Kafka topic name used for the Sarama instrumentation example. ```go const ( // KafkaTopic name. KafkaTopic = "sarama-instrumentation-example" ) ``` -------------------------------- ### HelloService Methods Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/example/api Details the available methods for the HelloService gRPC service, including SayHello, SayHelloServerStream, SayHelloClientStream, and SayHelloBidiStream. ```APIDOC ## HelloService Methods ### SayHello This is a standard unary RPC where the client sends a single request and receives a single response. * **Method:** Unary RPC * **Request Type:** HelloRequest * **Response Type:** HelloResponse ### SayHelloServerStream This is a server-streaming RPC where the client sends a single request and receives a stream of responses. * **Method:** Server Streaming RPC * **Request Type:** HelloRequest * **Response Type:** Stream of HelloResponse ### SayHelloClientStream This is a client-streaming RPC where the client sends a stream of requests and receives a single response. * **Method:** Client Streaming RPC * **Request Type:** Stream of HelloRequest * **Response Type:** HelloResponse ### SayHelloBidiStream This is a bidirectional streaming RPC where both the client and server send streams of messages. * **Method:** Bidirectional Streaming RPC * **Request Type:** Stream of HelloRequest * **Response Type:** Stream of HelloResponse ``` -------------------------------- ### SubOperation Source: https://pkg.go.dev/go.opentelemetry.io/contrib/examples/namedtracer/foo SubOperation is an example to demonstrate the use of named tracer. It creates a named tracer with its package path. ```APIDOC ## func SubOperation ### Description SubOperation is an example to demonstrate the use of named tracer. It creates a named tracer with its package path. ### Signature ```go func SubOperation(ctx context.Context) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response - None #### Error Response - error (error) - An error if the operation fails. ``` -------------------------------- ### Get Severity Value Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev Retrieves the severity value associated with a SeverityVar. This method is available from v0.4.0 onwards. ```go func (v *SeverityVar) Severity() log.Severity ``` -------------------------------- ### Get Jaeger Header Fields Source: https://pkg.go.dev/go.opentelemetry.io/contrib/propagators/jaeger Returns the Jaeger header key whose value is set with Inject. ```go func (Jaeger) Fields() []string ``` -------------------------------- ### Create DogStatsD Export Pipeline Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/dogstatsd Sets up a complete export pipeline with recommended components, chaining a NewRawExporter into selectors and batchers. ```go func NewExportPipeline(config Config, opts ...controller.Option) (*controller.Controller, error) ``` -------------------------------- ### Get Template Name as KeyValue Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego Returns the template name as a KeyValue pair for use in OpenTelemetry labels. ```go func Template(name string) label.KeyValue ``` -------------------------------- ### NewResource Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrgen/rtlib Generates a resource that describes the current application. ```go func NewResource() *resource.Resource { } ``` -------------------------------- ### NewExportPipeline Source: https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/metric/dogstatsd Creates a new export pipeline with a recommended setup, chaining a raw exporter with selectors and batchers. ```APIDOC ## NewExportPipeline ### Description Sets up a complete export pipeline with the recommended setup, chaining a NewRawExporter into the recommended selectors and batchers. ### Function Signature ``` func NewExportPipeline(config Config, opts ...controller.Option) (*controller.Controller, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **controller.Controller**: A controller for managing the export pipeline. - **error**: An error if the pipeline could not be created. #### Response Example None ``` -------------------------------- ### SpanProcessor.OnStart Source: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/baggagecopy Called when a span is started. This method adds span attributes for baggage contents based on the configured filter. ```APIDOC ## func (SpanProcessor) OnStart(ctx context.Context, span trace.ReadWriteSpan) ### Description This method is invoked when a span begins execution. It enriches the span by adding attributes derived from the baggage in the provided context, subject to the processor's filter. ### Parameters #### Path Parameters - **ctx** (context.Context) - Required - The context for the operation. - **span** (trace.ReadWriteSpan) - Required - The span being started, which will be modified with baggage attributes. ``` -------------------------------- ### Initialize Tracer Function Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/example Placeholder function for initializing the tracer. Actual implementation would configure the OpenTelemetry tracer. ```go func InitTracer() { } ``` -------------------------------- ### MethodPrefix Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters MethodPrefix returns a Filter that returns true if the request's method starts with the provided string pre. ```APIDOC ## MethodPrefix ### Description Returns a Filter that returns true if the request's method starts with the provided string pre. ### Signature ``` func MethodPrefix(pre string) otelgrpc.Filter ``` ``` -------------------------------- ### NewHelloServiceClient Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/example/api Creates a new HelloServiceClient. ```APIDOC ## NewHelloServiceClient ### Description Creates a new HelloServiceClient. ### Parameters - **cc** (*grpc.ClientConn) - The client connection to use. ``` -------------------------------- ### Create Fallback Sampler Source: https://pkg.go.dev/go.opentelemetry.io/contrib/samplers/aws/xray Instantiates a FallbackSampler that samples 1 request per second and an additional 5% of requests using a traceIDRatioBasedSampler. ```go func NewFallbackSampler() *FallbackSampler ``` -------------------------------- ### NewSDK Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf Creates SDK providers based on the configuration model. It checks the local environment and uses the file set in the variable OTEL_CONFIG_FILE to configure the SDK automatically. Any file defined by OTEL_CONFIG_FILE will supersede all files passed with WithOpenTelemetryConfiguration. ```APIDOC ## func NewSDK ### Description Creates SDK providers based on the configuration model. It checks the local environment and uses the file set in the variable `OTEL_CONFIG_FILE` to configure the SDK automatically. Any file defined by `OTEL_CONFIG_FILE` will supersede all files passed with `WithOpenTelemetryConfiguration`. ### Signature ```go func NewSDK(opts ...ConfigurationOption) (SDK, error) ``` ### Parameters #### Options (`opts`) - `...ConfigurationOption`: A variadic list of configuration options to customize the SDK setup. ``` -------------------------------- ### Get Resource Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf/v0.3.0 Returns a copy of the resolved SDK resource. The copy ensures the SDK-owned resource remains immutable. ```go func (s *SDK) Resource() *sdkresource.Resource ``` -------------------------------- ### Get Jaeger Remote Sampler Description Source: https://pkg.go.dev/go.opentelemetry.io/contrib/samplers/jaegerremote Returns a human-readable name for the Sampler. This can be useful for logging or identification purposes. ```go func (*Sampler) Description() string ``` -------------------------------- ### LogSink.Init Source: https://pkg.go.dev/go.opentelemetry.io/contrib/bridges/otellogr Initializes the LogSink with optional runtime information. This implementation does not utilize the provided information. ```APIDOC ## LogSink.Init ### Description Initializes the LogSink with optional runtime information. This implementation does not utilize the provided information. ### Signature ```go func (*LogSink) Init(logr.RuntimeInfo) ``` ``` -------------------------------- ### Enable Tracing with NewSessionWithTracing Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql Use `NewSessionWithTracing` to create a new gocql session with tracing enabled for queries, batch queries, and connection attempts. You can pass additional options to customize the instrumentation. ```go package main import ( "context" "github.com/gocql/gocql" otelGocql "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql" ) func main() { // Create a cluster host := "localhost" cluster := gocql.NewCluster(host) // Create a session with tracing session, err := otelGocql.NewSessionWithTracing( context.Background(), cluster, // Include any options here ) // Begin using the session } ``` -------------------------------- ### Get Environment Variable Source: https://pkg.go.dev/go.opentelemetry.io/contrib/propagators/envcar Retrieves the value associated with a normalized key from the environment. Reads from environment on first call. ```go func (c *Carrier) Get(key string) string ``` -------------------------------- ### HelloService_SayHelloClientStreamServer Interface Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/example/api Server-side interface for client-side streaming in SayHelloClientStream. ```go type HelloService_SayHelloClientStreamServer interface { SendAndClose(*HelloResponse) error Recv() (*HelloRequest, error) grpc.ServerStream } ``` -------------------------------- ### HelloServiceServer Interface Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/example/api Defines the server interface for the Hello service, including methods for SayHello and various streaming operations. ```go type HelloServiceServer interface { SayHello(context.Context, *HelloRequest) (*HelloResponse, error) SayHelloServerStream(*HelloRequest, HelloService_SayHelloServerStreamServer) error SayHelloClientStream(HelloService_SayHelloClientStreamServer) error SayHelloBidiStream(HelloService_SayHelloBidiStreamServer) error } ``` -------------------------------- ### MethodPrefix Filter Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters Filters requests where the method name starts with a specified prefix. Useful for instrumenting a group of related methods. ```go func MethodPrefix(pre string) otelgrpc.Filter ``` -------------------------------- ### Configure Endpoint Middleware with Operation Name Getter Source: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit Option to set a function for dynamically getting the operation name in the configuration. ```go func WithOperationGetter(fn func(ctx context.Context, name string) string) Option ``` -------------------------------- ### Define Experimental Resource Detector Configuration Source: https://pkg.go.dev/go.opentelemetry.io/contrib/otelconf/x Configure individual resource detectors like container, host, process, and service. If omitted, the respective detector is ignored. ```go type ExperimentalResourceDetector struct { // Enable the container resource detector, which populates container.* attributes. // If omitted, ignore. // Container ExperimentalContainerResourceDetector `json:"container,omitempty,omitzero" yaml:"container,omitempty" mapstructure:"container,omitempty"` // Enable the host resource detector, which populates host.* and os.* attributes. // If omitted, ignore. // Host ExperimentalHostResourceDetector `json:"host,omitempty,omitzero" yaml:"host,omitempty" mapstructure:"host,omitempty"` // Enable the process resource detector, which populates process.* attributes. // If omitted, ignore. // Process ExperimentalProcessResourceDetector `json:"process,omitempty,omitzero" yaml:"process,omitempty" mapstructure:"process,omitempty"` // Enable the service detector, which populates service.name based on the // OTEL_SERVICE_NAME environment variable and service.instance.id. // If omitted, ignore. // Service ExperimentalServiceResourceDetector `json:"service,omitempty,omitzero" yaml:"service,omitempty" mapstructure:"service,omitempty"` AdditionalProperties interface{} `mapstructure:",remain"` } ```