Skip to content

Commit

Permalink
Expose more instrumentation library scope names
Browse files Browse the repository at this point in the history
  • Loading branch information
utezduyar committed Nov 1, 2023
1 parent 2ab2ed5 commit 3ab611a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions instrumentation/google.golang.org/grpc/otelgrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
)

const (
// instrumentationName is the name of this instrumentation package.
instrumentationName = "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
// ScopeName is the instrumentation scope name.
ScopeName = "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
// GRPCStatusCodeKey is convention for numeric status code of a gRPC request.
GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code")
)
Expand Down Expand Up @@ -67,7 +67,7 @@ func newConfig(opts []Option) *config {
}

c.meter = c.MeterProvider.Meter(
instrumentationName,
ScopeName,
metric.WithInstrumentationVersion(Version()),
metric.WithSchemaURL(semconv.SchemaURL),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var (
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor {
cfg := newConfig(opts)
tracer := cfg.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(Version()),
)

Expand Down Expand Up @@ -257,7 +257,7 @@ func (w *clientStream) sendStreamEvent(eventType streamEventType, err error) {
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
cfg := newConfig(opts)
tracer := cfg.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(Version()),
)

Expand Down Expand Up @@ -327,7 +327,7 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
cfg := newConfig(opts)
tracer := cfg.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(Version()),
)

Expand Down Expand Up @@ -448,7 +448,7 @@ func wrapServerStream(ctx context.Context, ss grpc.ServerStream, cfg *config) *s
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
cfg := newConfig(opts)
tracer := cfg.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(Version()),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewServerHandler(opts ...Option) stats.Handler {
}

h.tracer = h.config.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(SemVersion()),
)
return h
Expand Down Expand Up @@ -94,7 +94,7 @@ func NewClientHandler(opts ...Option) stats.Handler {
}

h.tracer = h.config.TracerProvider.Tracer(
instrumentationName,
ScopeName,
trace.WithInstrumentationVersion(SemVersion()),
)

Expand Down
5 changes: 4 additions & 1 deletion instrumentation/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import (
"go.opentelemetry.io/otel/metric"
)

// ScopeName is the instrumentation scope name.
const ScopeName string = "go.opentelemetry.io/contrib/instrumentation/host"

// Host reports the work-in-progress conventional host metrics specified by OpenTelemetry.
type host struct {
config config
Expand Down Expand Up @@ -102,7 +105,7 @@ func Start(opts ...Option) error {
}
h := &host{
meter: c.MeterProvider.Meter(
"go.opentelemetry.io/contrib/instrumentation/host",
ScopeName,

Check warning on line 108 in instrumentation/host/host.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/host/host.go#L108

Added line #L108 was not covered by tests
metric.WithInstrumentationVersion(Version()),
),
config: c,
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ const (
type Filter func(*http.Request) bool

func newTracer(tp trace.TracerProvider) trace.Tracer {
return tp.Tracer(instrumentationName, trace.WithInstrumentationVersion(Version()))
return tp.Tracer(ScopeName, trace.WithInstrumentationVersion(Version()))
}
7 changes: 3 additions & 4 deletions instrumentation/net/http/otelhttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"go.opentelemetry.io/otel/trace"
)

const (
instrumentationName = "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
// ScopeName is the instrumentation scope name.
const ScopeName string = "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"

// config represents the configuration options available for the http.Handler
// and http.Transport types.
Expand Down Expand Up @@ -76,7 +75,7 @@ func newConfig(opts ...Option) *config {
}

c.Meter = c.MeterProvider.Meter(
instrumentationName,
ScopeName,
metric.WithInstrumentationVersion(Version()),
)

Expand Down

0 comments on commit 3ab611a

Please sign in to comment.