Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fc09e2c
final rebase with master
aranjans Dec 9, 2024
2747371
update e2e tests
aranjans Dec 9, 2024
96f92a0
fix e2e tests
aranjans Dec 10, 2024
f650e37
remove fmt logs
aranjans Dec 10, 2024
175d4c5
move grpc_trace_bin_propagator to experimental
aranjans Dec 11, 2024
c30c44a
move TraceOptions api to experimental
aranjans Dec 11, 2024
90ffa23
addressed purnesh's comments
aranjans Dec 16, 2024
2083830
don't change opentelemetry/e2e_test.go package name from opentelemetr…
aranjans Dec 16, 2024
e8e9d53
make vet happy
aranjans Dec 16, 2024
57fd38a
update TestServerWithMetricsAndTraceOptions
aranjans Dec 17, 2024
b0aad8a
fixed nits
aranjans Dec 17, 2024
8680ae8
fixed nits
aranjans Dec 17, 2024
98d11b7
fix: small nits
aranjans Dec 18, 2024
d0e1a0a
Add test with metrics and traces disabled.
aranjans Dec 19, 2024
b6503f7
make vet happy
aranjans Dec 19, 2024
b2831f1
pull out logic to find name resolution delay
aranjans Dec 20, 2024
1cb4396
remove experimental notice from grpc_trace_bin_propagator
aranjans Dec 20, 2024
b8fe8db
refactor and addressed comments from doug
aranjans Dec 23, 2024
d4ae3ab
Add copyright notice to client_tracing.go
aranjans Dec 23, 2024
c705b97
let client set the propagator and trace provider
aranjans Dec 24, 2024
5571e3b
fix breaking tests
aranjans Dec 24, 2024
6e06350
move call span creation to client_tracing.go
aranjans Jan 2, 2025
cfb92ae
move grpc_trace_bin_propagator -> stats/opentelemetry
aranjans Jan 13, 2025
72e178b
nits
aranjans Jan 15, 2025
5beafe1
disable tracing if textMapPropagator is not set, even if traceProvide…
aranjans Jan 15, 2025
8e15369
return noop interceptor if traceoptions are not defined properly
aranjans Jan 21, 2025
d5913b6
make vet happy
aranjans Jan 21, 2025
afbf947
fix nits
aranjans Jan 24, 2025
2fc523f
add test for rpc error
aranjans Jan 28, 2025
c1569fc
make vet happy
aranjans Jan 28, 2025
374b933
address purnesh comments
aranjans Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions experimental/opentelemetry/trace_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

// This package is EXPERIMENTAL and may be move to stats/opentelemetry package
// in a later release.
// Package opentelemetry is EXPERIMENTAL and may be moved to stats/opentelemetry
// package in a later release.
package opentelemetry

import (
Expand Down
2 changes: 1 addition & 1 deletion stats/opentelemetry/client_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// It creates a new outgoing carrier which serializes information about this
// span into gRPC Metadata, if TextMapPropagator is provided in the trace
// options. if TextMapPropagator is not provided, it returns the context as is.
func (h *clientStatsHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo, ai *attemptInfo) (context.Context, *attemptInfo) {
func (h *clientStatsHandler) traceTagRPC(ctx context.Context, _ *stats.RPCTagInfo, ai *attemptInfo) (context.Context, *attemptInfo) {
mn := "Attempt." + strings.Replace(ai.method, "/", ".", -1)
tracer := otel.Tracer("grpc-open-telemetry")
ctx, span := tracer.Start(ctx, mn)
Expand All @@ -45,9 +45,9 @@
// provided TraceProvider. If TraceProvider is nil, it returns context as is.
func (h *clientStatsHandler) createCallTraceSpan(ctx context.Context, method string) (context.Context, trace.Span) {
if h.options.TraceOptions.TracerProvider == nil {
logger.Error("TraceProvider is not provided in trace options")
return ctx, nil
}

Check warning on line 50 in stats/opentelemetry/client_tracing.go

View check run for this annotation

Codecov / codecov/patch

stats/opentelemetry/client_tracing.go#L48-L50

Added lines #L48 - L50 were not covered by tests
mn := strings.Replace(removeLeadingSlash(method), "/", ".", -1)
tracer := otel.Tracer("grpc-open-telemetry")
ctx, span := tracer.Start(ctx, mn, trace.WithSpanKind(trace.SpanKindClient))
Expand Down
18 changes: 17 additions & 1 deletion stats/opentelemetry/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,23 @@
}

func (o *Options) isTracingEnabled() bool {
return o.TraceOptions.TextMapPropagator != nil
// Check if both TextMapPropagator and TracerProvider are set.
isTextMapPropagatorSet := o.TraceOptions.TextMapPropagator != nil
isTracerProviderSet := o.TraceOptions.TracerProvider != nil

// Return false if neither option is set.
if !isTextMapPropagatorSet && !isTracerProviderSet {
return false
}

// Log an error if one of the options is missing.
if isTextMapPropagatorSet != isTracerProviderSet {
logger.Error("traceOptions are not set properly: one of TextMapPropagator or TracerProvider is missing.")
return false
}

Check warning on line 82 in stats/opentelemetry/opentelemetry.go

View check run for this annotation

Codecov / codecov/patch

stats/opentelemetry/opentelemetry.go#L80-L82

Added lines #L80 - L82 were not covered by tests

// Both options are set, return true.
return true
}

// MetricsOptions are the metrics options for OpenTelemetry instrumentation.
Expand Down
2 changes: 1 addition & 1 deletion stats/opentelemetry/server_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
// is set as parent of the new span otherwise new span remains the root span.
// If TextMapPropagator is not provided in the trace options, it returns context
// as is.
func (h *serverStatsHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo, ai *attemptInfo) (context.Context, *attemptInfo) {
func (h *serverStatsHandler) traceTagRPC(ctx context.Context, _ *stats.RPCTagInfo, ai *attemptInfo) (context.Context, *attemptInfo) {
mn := strings.Replace(ai.method, "/", ".", -1)
var span trace.Span
tracer := otel.Tracer("grpc-open-telemetry")
Expand Down
Loading