Skip to content

Commit

Permalink
Merge branch 'main' into cgo_0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Oct 31, 2024
2 parents 963e6db + 77e8de9 commit b35b7c0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http

## [Unreleased]

### Changed

- The SDK provided in `go.opentelemtry.io/auto/sdk` now defaults to NoOp behavior for unimplemented methods of the OpenTelemetry API.
This is changed from causing a compilation error for unimplemented methods. ([#1230](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1230))
- The `GetTracerProvider` fucntion in `go.opentelemtry.io/auto/sdk` is renamed to `TracerProvider`. ([#1231](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1231))

### Fixed

- Sporadic shutdown deadlock. ([#1220](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1220))
Expand Down
2 changes: 1 addition & 1 deletion internal/test/e2e/autosdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() {
// give time for auto-instrumentation to start up
time.Sleep(5 * time.Second)

provider := sdk.GetTracerProvider()
provider := sdk.TracerProvider()
tracer := provider.Tracer(
pkgName,
trace.WithInstrumentationVersion(pkgVer),
Expand Down
4 changes: 2 additions & 2 deletions sdk/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package sdk

import "context"

func ExampleGetTracerProvider() {
func ExampleTracerProvider() {
// Get a Tracer from an auto-instrumented TracerProvider so all spans
// created will be passed to the auto-instrumentation telemetry pipeline.
tracer := GetTracerProvider().Tracer("my.pkg/name")
tracer := TracerProvider().Tracer("my.pkg/name")

// The tracer is used normally to create spans to encapsulate work.
_, span := tracer.Start(context.Background(), "do.work")
Expand Down
14 changes: 7 additions & 7 deletions sdk/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ import (
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
"go.opentelemetry.io/otel/trace/noop"

"go.opentelemetry.io/auto/sdk/telemetry"
)

// GetTracerProvider returns an auto-instrumentable [trace.TracerProvider].
// TracerProvider returns an auto-instrumentable [trace.TracerProvider].
//
// If an [go.opentelemetry.io/auto.Instrumentation] is configured to instrument
// the process using the returned TracerProvider, all of the telemetry it
// produces will be processed and handled by that Instrumentation. By default,
// if no Instrumentation instruments the TracerProvider it will not generate
// any trace telemetry.
func GetTracerProvider() trace.TracerProvider { return tracerProviderInstance }
func TracerProvider() trace.TracerProvider { return tracerProviderInstance }

var tracerProviderInstance = tracerProvider{}

type tracerProvider struct{ embedded.TracerProvider }
type tracerProvider struct{ noop.TracerProvider }

var _ trace.TracerProvider = tracerProvider{}

Expand All @@ -45,7 +45,7 @@ func (p tracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.Tr
}

type tracer struct {
embedded.Tracer
noop.Tracer

name, schemaURL, version string
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func spanKind(kind trace.SpanKind) telemetry.SpanKind {
}

type span struct {
embedded.Span
noop.Span

sampled bool
spanContext trace.SpanContext
Expand Down Expand Up @@ -383,4 +383,4 @@ func (s *span) SetName(name string) {
s.span.Name = name
}

func (*span) TracerProvider() trace.TracerProvider { return GetTracerProvider() }
func (*span) TracerProvider() trace.TracerProvider { return TracerProvider() }
2 changes: 1 addition & 1 deletion sdk/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestSpanCreation(t *testing.T) {

ts := time.Now()

tracer := GetTracerProvider().Tracer(
tracer := TracerProvider().Tracer(
tracerName,
trace.WithInstrumentationVersion(tracerVer),
trace.WithSchemaURL(semconv.SchemaURL),
Expand Down

0 comments on commit b35b7c0

Please sign in to comment.