1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
OpenTelemetry Go API and SDK https://opentelemetry.io/
Go to file
Krzesimir Nowak 29cd0c08b7
Fix a possible nil-dereference crash (#478)
* Test for a panic inside global internal meter instrument's Unbind

* Fix a possible nil-dereference crash

There is a nil dereference crash if we perform some operations in
certain order:

- get a global meter
- create an instrument
- bind it
- set the delegate
- unbind the instrument
- call some recording function on the not-really-bound-anymore
  instrument

Unbind will run the no op run-once initialization routine, so the
follow-up RecordOne call will not run it's initialization
routine. Which RecordOne's initialization routine being skipped, the
delegate to bounded instrument is not set, but the code is still
trying to get a pointer to it and then unconditionally dereference it.

Add an extra check for a nil pointer - if this is true, then Unbind
was first and RecordOne should effectively be a no op.

Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
2020-02-20 13:05:19 -08:00
.circleci Use latest version of golang 1.13 in CI (#465) 2020-02-04 21:21:15 -08:00
api Fix a possible nil-dereference crash (#478) 2020-02-20 13:05:19 -08:00
bridge/opentracing Add StartOptions to Tracer.WithSpan() (#472) 2020-02-10 21:07:32 -05:00
example Move dependencies of tools package to a tools directory (#466) 2020-02-06 10:51:00 -08:00
exporter exporter/metric/stdout: fix incorrect code format comments for InstallNewPipeline (#483) 2020-02-20 09:03:18 -08:00
internal Do not always put remote span context into links (#480) 2020-02-14 09:21:39 -08:00
plugin Move correlation context propagation to correlation package (#479) 2020-02-20 10:31:21 -08:00
sdk Add StartOptions to Tracer.WithSpan() (#472) 2020-02-10 21:07:32 -05:00
tools Move dependencies of tools package to a tools directory (#466) 2020-02-06 10:51:00 -08:00
.gitignore Consistently use pointer receivers for core.Number (#375) 2019-12-09 13:03:11 -08:00
.golangci.yml Enable golint & gofmt, resolve issues (#214) 2019-10-16 10:24:38 -07:00
CODEOWNERS Add @MrAlias as an approver (#471) 2020-02-10 19:36:04 -05:00
CONTRIBUTING.md Add @MrAlias as an approver (#471) 2020-02-10 19:36:04 -05:00
get_main_pkgs.sh Use /usr/bin/env bash rather than /bin/bash (#336) 2019-11-21 16:19:11 -08:00
go.mod Move dependencies of tools package to a tools directory (#466) 2020-02-06 10:51:00 -08:00
go.sum Move dependencies of tools package to a tools directory (#466) 2020-02-06 10:51:00 -08:00
LICENSE Initial commit 2019-05-16 12:05:27 -07:00
Makefile Move dependencies of tools package to a tools directory (#466) 2020-02-06 10:51:00 -08:00
README.md Document compatible exporters in a neutral fashion (#405) 2019-12-31 13:48:24 -05:00
tag_latest_modules.sh module tag script for releng (#414) 2020-01-06 13:20:43 -05:00

OpenTelemetry-Go

Circle CI Docs Go Report Card Gitter

The Go OpenTelemetry client.

Installation

This repository includes multiple packages. The api package contains core data types, interfaces and no-op implementations that comprise the OpenTelemetry API following the specification. The sdk package is the reference implementation of the API.

Libraries that produce telemetry data should only depend on api and defer the choice of the SDK to the application developer. Applications may depend on sdk or another package that implements the API.

To install the API and SDK packages,

$ go get -u go.opentelemetry.io/otel

Quick Start

package main

import (
	"context"
	"log"

	"go.opentelemetry.io/otel/api/global"
	"go.opentelemetry.io/otel/exporter/trace/stdout"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func initTracer() {
	exporter, err := stdout.NewExporter(stdout.Options{PrettyPrint: true})
	if err != nil {
		log.Fatal(err)
	}
	tp, err := sdktrace.NewProvider(sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
		sdktrace.WithSyncer(exporter))
	if err != nil {
		log.Fatal(err)
	}
	global.SetTraceProvider(tp)
}

func main() {
	initTracer()
	tracer := global.TraceProvider().Tracer("ex.com/basic")

	tracer.WithSpan(context.Background(), "foo",
		func(ctx context.Context) error {
			tracer.WithSpan(ctx, "bar",
				func(ctx context.Context) error {
					tracer.WithSpan(ctx, "baz",
						func(ctx context.Context) error {
							return nil
						},
					)
					return nil
				},
			)
			return nil
		},
	)
}

See the API documentation for more detail, and the opentelemetry-example-app for a complete example.

Compatible Exporters

See the Go packages depending upon sdk/export/trace and sdk/export/metric for a list of all exporters compatible with OpenTelemetry's Go SDK.

Contributing

See the contributing file.

Release Schedule

OpenTelemetry Go is under active development. Below is the release schedule for the Go library. The first version of the release isn't guaranteed to conform to a specific version of the specification, and future releases will not attempt to maintain backward compatibility with the alpha release.

Component Version Target Date Release Date
Tracing API Alpha v0.1.0 October 28 2019 November 05 2019
Tracing SDK Alpha v0.1.0 October 28 2019 November 05 2019
Jaeger Trace Exporter Alpha v0.1.0 October 28 2019 November 05 2019
Trace Context Propagation Alpha v0.1.0 Unknown November 05 2019
OpenTracing Bridge Alpha v0.1.0 October November 05 2019
Metrics API Alpha v0.2.0 October 28 2019 December 03 2019
Metrics SDK Alpha v0.2.0 October 28 2019 December 03 2019
Prometheus Metrics Exporter Alpha v0.2.0 October 28 2019 December 03 2019
Context Prop. rename/Baggage Alpha v0.3.0 December 23 2019 -
OpenTelemetry Collector Exporter Alpha v0.4.0 January 15 2020 -
Zipkin Trace Exporter Alpha Unknown -
OpenCensus Bridge Alpha Unknown -