-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stats/opentelemetry: Introduce Tracing API #7852
Open
aranjans
wants to merge
22
commits into
grpc:master
Choose a base branch
from
aranjans:a72
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fc09e2c
final rebase with master
aranjans 2747371
update e2e tests
aranjans 96f92a0
fix e2e tests
aranjans f650e37
remove fmt logs
aranjans 175d4c5
move grpc_trace_bin_propagator to experimental
aranjans c30c44a
move TraceOptions api to experimental
aranjans 90ffa23
addressed purnesh's comments
aranjans 2083830
don't change opentelemetry/e2e_test.go package name from opentelemetr…
aranjans e8e9d53
make vet happy
aranjans 57fd38a
update TestServerWithMetricsAndTraceOptions
aranjans b0aad8a
fixed nits
aranjans 8680ae8
fixed nits
aranjans 98d11b7
fix: small nits
aranjans d0e1a0a
Add test with metrics and traces disabled.
aranjans b6503f7
make vet happy
aranjans b2831f1
pull out logic to find name resolution delay
aranjans 1cb4396
remove experimental notice from grpc_trace_bin_propagator
aranjans b8fe8db
refactor and addressed comments from doug
aranjans d4ae3ab
Add copyright notice to client_tracing.go
aranjans c705b97
let client set the propagator and trace provider
aranjans 5571e3b
fix breaking tests
aranjans 6e06350
move call span creation to client_tracing.go
aranjans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package experimental | ||
|
||
import ( | ||
"go.opentelemetry.io/otel/propagation" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// TraceOptions are the tracing options for OpenTelemetry instrumentation. | ||
type TraceOptions struct { | ||
// TracerProvider is the OpenTelemetry tracer which is required to | ||
// record traces/trace spans for instrumentation | ||
TracerProvider trace.TracerProvider | ||
|
||
// TextMapPropagator propagates span context through text map carrier. | ||
TextMapPropagator propagation.TextMapPropagator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package opentelemetry | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"go.opentelemetry.io/otel" | ||
"google.golang.org/grpc/stats" | ||
otelinternaltracing "google.golang.org/grpc/stats/opentelemetry/internal/tracing" | ||
) | ||
|
||
// traceTagRPC populates provided context with a new span using the | ||
// TextMapPropagator supplied in trace options and internal itracing.carrier. | ||
// 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) { | ||
if h.options.TraceOptions.TextMapPropagator == nil { | ||
return ctx, nil | ||
} | ||
|
||
mn := "Attempt." + strings.Replace(removeLeadingSlash(rti.FullMethodName), "/", ".", -1) | ||
tracer := otel.Tracer("grpc-open-telemetry") | ||
ctx, span := tracer.Start(ctx, mn) | ||
carrier := otelinternaltracing.NewOutgoingCarrier(ctx) | ||
otel.GetTextMapPropagator().Inject(ctx, carrier) | ||
ai.traceSpan = span | ||
return carrier.Context(), ai | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can move to client_tracing.go? because it is applicable only to tracing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR, thAnks.