OpenTelemetry-Go Contrib

repository·main·Indexed 23 days ago

https://github.com/open-telemetry/opentelemetry-go-contrib

A repository of community-contributed extensions for the OpenTelemetry-Go SDK. It provides instrumentation for third-party libraries, custom propagators, exporters, and resource detectors for various cloud environments including AWS (Lambda, EC2, ECS, EKS), Azure (App Service, Container Apps, Functions, VM), GCP, Hetzner Cloud, IBM Cloud VPC, Vultr, and Kubernetes API.

Tokens
71.8K
Snippets
106
Records
544
Agent score
82%

What's inside opentelemetry-go-contrib

  1. Overview of OpenTelemetry-Go Contrib

    main

    OpenTelemetry-Go Contrib is a collection of 3rd-party packages designed to extend the core OpenTelemetry-Go ecosystem. It provides additional functionality for instrumentation, propagation, resource detection, and data export.

    The repository is organized into several functional categories:

    • Instrumentation: Packages that provide OpenTelemetry instrumentation for 3rd-party libraries.
    • Propagators: Packages providing context propagators for 3rd-party propagation formats.
    • Detectors: Resource detectors for identifying 3rd-party cloud computing environments.
    • Exporters: Exporters for 3rd-party export formats.
    • Samplers: Additional implementations of OpenTelemetry samplers.
    • Bridges: Adapters for 3rd-party instrumentation frameworks.
    • Processors: Additional implementations of OpenTelemetry processors.
  2. Use the Azure App Service Resource Detector

    main
    The Azure App Service Resource Detector is a component of the OpenTelemetry Go Contrib library designed to automatically detect and populate resource attributes when your application is running on Azure App Service. It identifies the specific Azure App Service environment and adds relevant metadata to your OpenTelemetry resources, which helps in correlating telemetry with your Azure infrastructure.
  3. Discover and use instrumentation packages

    main

    The instrumentation/ directory contains instrumentation for 3rd-party Go packages and parts of the standard library. You can use these to automatically collect Traces and Metrics for your application's dependencies.

    To find the most up-to-date list of available instrumentation, consult the OpenTelemetry registry.

    Commonly supported packages include:

    • Web Frameworks: gin (otelgin), echo (otelecho), gorilla/mux (otelmux), go-restful (otelrestful).
    • Database/Drivers: mongo-driver (otelmongo), grpc (otelgrpc).
    • Standard Library: net/http (otelhttp), net/http/httptrace (otelhttptrace).
    • Cloud SDKs: aws-sdk-go-v2 (otelaws).
  4. How Passthrough setup affects trace visualization

    main

    In a distributed system, if a component in the middle of a call chain (e.g., Outer -> Passthrough -> Inner) only has propagators configured and lacks an SDK TracerProvider, it will not create its own spans.

    In a standard setup where all components have an SDK, the trace would look like:

    |-------outer---------|
     |-Passthrough recv-| 
      |Passthrough send| 
        |---inner---| 

    In a Passthrough setup where the middle component only has propagators, the trace will skip the middle component's spans and appear as if the outer component called the inner component directly:

    |-------outer---------|
        |---inner---|