Documentation ¶
Overview ¶
azotel adapts OpenTelemetry tracing for consumption by the azcore/tracing package.
Example (JaegerExporter) ¶
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/Azure/azure-sdk-for-go/sdk/tracing/azotel" "go.opentelemetry.io/otel/exporters/jaeger" "go.opentelemetry.io/otel/sdk/resource" otelsdk "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.17.0" ) func main() { // end-to-end example creating an OTel TracerProvider that exports to Jaeger // then uses the azotel adapter to conenct it to an Azure SDK client. // create the Jaeger exporter exp, err := jaeger.New(jaeger.WithCollectorEndpoint()) if err != nil { log.Fatal(err) } // create an OTel TracerProvider that uses the Jaeger exporter otelTP := otelsdk.NewTracerProvider( otelsdk.WithBatcher(exp), otelsdk.WithResource(resource.NewWithAttributes( semconv.SchemaURL, semconv.ServiceNameKey.String("Example_jaegerExporter"), )), ) // create a credential for the Azure SDK client credential, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatal(err) } // create an Azure SDK client, connecting the OTel TracerProvider to it client, err := armresources.NewClientFactory("<subscription ID>", credential, &arm.ClientOptions{ ClientOptions: azcore.ClientOptions{ TracingProvider: azotel.NewTracingProvider(otelTP, nil), }, }) if err != nil { log.Fatal(err) } // make various API calls with the client. each one will create its own span _, err = client.NewClient().CheckExistenceByID(context.TODO(), "<resource ID>", "<api-version>", nil) if err != nil { log.Fatal(err) } // shut down the tracing provider to flush all spans to Jaeger if err = otelTP.Shutdown(context.TODO()); err != nil { log.Fatal(err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTracingProvider ¶
func NewTracingProvider(tracerProvider trace.TracerProvider, opts *TracingProviderOptions) tracing.Provider
NewTracingProvider creates a new tracing.Provider that wraps the specified OpenTelemetry TracerProvider.
- tracerProvider - the TracerProvider to wrap
- opts - optional configuration. pass nil to accept the default values
Types ¶
type TracingProviderOptions ¶
type TracingProviderOptions struct { }
TracingProviderOptions contains the optional values for NewTracingProvider.
Click to show internal directories.
Click to hide internal directories.