Skip to content
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

Merged
merged 31 commits into from
Jan 30, 2025
Merged

Conversation

aranjans
Copy link
Contributor

@aranjans aranjans commented Nov 18, 2024

This pull request adds the OpenTelemetry tracing API to the grpc-go opentelemetry plugin as outlined in proposal A72.

RELEASE NOTES:

  • stats/opentelemetry: Introduces an experimental API for enabling and configuring OpenTelemetry tracing within gRPC-go opentelemetry plugin under stats/opentelemetry/experimental. This includes the addition of TraceOptions in the Options struct to allow users to specify the TraceProvider and TextMapPropagator.

@aranjans aranjans added this to the 1.69 Release milestone Nov 18, 2024
@aranjans aranjans added Type: Feature New features or improvements in behavior Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability labels Nov 18, 2024
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 88.97059% with 15 lines in your changes missing coverage. Please review.

Project coverage is 82.25%. Comparing base (56a14ba) to head (374b933).
Report is 46 commits behind head on master.

Files with missing lines Patch % Lines
stats/opentelemetry/trace.go 83.33% 7 Missing and 1 partial ⚠️
stats/opentelemetry/client_tracing.go 76.47% 3 Missing and 1 partial ⚠️
stats/opentelemetry/opentelemetry.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7852      +/-   ##
==========================================
+ Coverage   82.09%   82.25%   +0.16%     
==========================================
  Files         379      387       +8     
  Lines       38261    39041     +780     
==========================================
+ Hits        31409    32114     +705     
- Misses       5549     5595      +46     
- Partials     1303     1332      +29     
Files with missing lines Coverage Δ
stats/opentelemetry/client_metrics.go 89.39% <100.00%> (+1.46%) ⬆️
stats/opentelemetry/server_metrics.go 89.82% <100.00%> (+0.44%) ⬆️
stats/opentelemetry/server_tracing.go 100.00% <100.00%> (ø)
stats/opentelemetry/opentelemetry.go 75.00% <62.50%> (-0.87%) ⬇️
stats/opentelemetry/client_tracing.go 76.47% <76.47%> (ø)
stats/opentelemetry/trace.go 83.33% <83.33%> (ø)

... and 59 files with indirect coverage changes

@aranjans aranjans requested a review from purnesh42H November 18, 2024 08:22
@purnesh42H purnesh42H self-assigned this Nov 19, 2024
@purnesh42H
Copy link
Contributor

@aranjans please update this with latest main branch to get rid of all go.mod and go.sum changes

@purnesh42H purnesh42H assigned aranjans and unassigned purnesh42H Nov 20, 2024
@aranjans aranjans force-pushed the a72 branch 3 times, most recently from 378ddd3 to 8cb8222 Compare November 21, 2024 17:44
@aranjans aranjans assigned purnesh42H and unassigned aranjans Nov 22, 2024
@aranjans
Copy link
Contributor Author

@purnesh42H Thanks for your review, I have addressed all your comments and this PR is ready for another pass.

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more non-test comments. Will review tests in next pass

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more non-test comments. Will review tests in next pass

@purnesh42H purnesh42H assigned aranjans and unassigned purnesh42H Nov 22, 2024
@purnesh42H purnesh42H changed the title Implement A72: OpenTelemetry Tracing stats/opentelemetry: Introduce Tracing API Nov 22, 2024
@purnesh42H
Copy link
Contributor

@aranjans you should link the gRFC and concise your description

@aranjans
Copy link
Contributor Author

aranjans commented Nov 23, 2024

@purnesh42H I have addressed all the comments, and updated the description to link the grfc proposal.
Feel free to close the thread which are resolved now.

@aranjans aranjans assigned purnesh42H and unassigned aranjans Nov 23, 2024
@aranjans
Copy link
Contributor Author

@purnesh42H I have addressed all your comments, and updated the PR. Kindly review the PR.

@arjan-bal arjan-bal modified the milestones: 1.70 Release, 1.71 Release Jan 22, 2025
@purnesh42H purnesh42H assigned dfawley and unassigned dfawley and purnesh42H Jan 23, 2025
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more small things otherwise LGTM

case *stats.End:
if rs.Error != nil {
s := status.Convert(rs.Error)
span.SetStatus(otelcodes.Error, s.Message())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there is missing coverage for this (RPC error) and PickerUpdated - could you add test cases for them, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dfawley I have added the test for rpc error, PTAL.

@dfawley dfawley assigned aranjans and unassigned dfawley Jan 23, 2025
@@ -87,6 +88,12 @@ func (h *clientStatsHandler) unaryInterceptor(ctx context.Context, method string
}
}

// Log an error if one of the options is missing.
if (h.options.TraceOptions.TextMapPropagator == nil) != (h.options.TraceOptions.TracerProvider == nil) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should happen in the constructor for the otel plugin. Not on every RPC.

)

func init() {
otelinternal.SetPluginOption = func(o *Options, po otelinternal.PluginOption) {
o.MetricsOptions.pluginOption = po
// Log an error if one of the options is missing.
if (o.TraceOptions.TextMapPropagator == nil) != (o.TraceOptions.TracerProvider == nil) {
logger.Error("traceOptions are not set properly: one of TextMapPropagator or TracerProvider is missing.")
Copy link
Contributor

@purnesh42H purnesh42H Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aranjans How about "Tracing will not be recorded because traceOptions are not set properly: one of TextMapPropagator or TracerProvider is missing"? Also, may be it should be warning instead of error because we are only treating it as no-op for tracing but continuing with setup? @dfawley cc

@aranjans aranjans assigned purnesh42H and dfawley and unassigned aranjans Jan 28, 2025
@purnesh42H purnesh42H removed their assignment Jan 29, 2025
@purnesh42H purnesh42H requested a review from dfawley January 29, 2025 03:52
@dfawley dfawley assigned purnesh42H and unassigned dfawley Jan 30, 2025
@purnesh42H purnesh42H merged commit 78eebff into grpc:master Jan 30, 2025
14 of 15 checks passed
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 13, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 13, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants