azure

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

README

OpenTelemetry Azure Monitor

Installation

go get github.com/adamko147/opentelemetry-azure-monitor

Usage

Trace

The Azure Monitor Span Exporter allows you to export OpenTelemetry traces to Azure Monitor.

This example shows how to send a span "hello" to Azure Monitor.

package main

import (
	"context"
	"log"

	appinsights "github.com/adamko147/opentelemetry-azure-monitor/appinsights"
	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/codes"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {
	ctx := context.Background()

	shutdown, err := appinsights.InstallNewPipeline(
		appinsights.WithProcess(appinsights.Process{
			ServiceName: "trace-demo",
		}),
		appinsights.WithInstrumentationKey("<instrumentation-key>")
		appinsights.WithOptions(
			sdktrace.WithSampler(sdktrace.AlwaysSample()),
		),
	)
	if err != nil {
		log.Fatal(err)
	}
	defer shutdown(ctx)

	tracer := otel.Tracer("my-module")
	_, span := tracer.Start(ctx, "operation")
	log.Println("Hello World")
	span.SetStatus(codes.Ok, "Succeeded")
	span.End()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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