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

OTEL wiring in grpcserver interceptor (DataDog POC) #612

Merged
merged 17 commits into from
Jul 22, 2024

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented May 30, 2024

This PR wires up OTEL tracing in gprcserver interceptor, allowing tracing requests that originate from external services.

I had to bump up go as 1.20 did not support some of the otel grpc dependencies.

This has led to bumping up go versions of a lot of the CI stuff.

Tested.

Copy link

coderabbitai bot commented May 30, 2024

Walkthrough

The recent updates introduce OpenTelemetry tracing into the gRPC server functionality within the codebase. This enhancement includes importing necessary OpenTelemetry libraries and incorporating tracing logic into the interceptor function and StartGRPCServer function. These changes aim to improve observability and monitoring of gRPC calls by capturing detailed tracing information.

Changes

Files Change Summary
baseapp/grpcserver.go Added OpenTelemetry tracing imports, tracerName constant, and modified interceptor function.
server/grpc/server.go Introduced OpenTelemetry instrumentation for gRPC, including otelgrpc.NewServerHandler().

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant gRPCServer
    participant OpenTelemetry

    Client->>gRPCServer: Send gRPC request
    gRPCServer->>OpenTelemetry: Start trace
    gRPCServer->>gRPCServer: Process request
    gRPCServer->>OpenTelemetry: End trace
    gRPCServer->>Client: Send response
Loading

Poem

In the code where gRPC roams,
Traces now find their homes.
With OpenTelemetry's might,
Observability takes flight.
Each request, a story told,
In spans of data, bright and bold.
🌟📡🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@p0mvn p0mvn reopened this Jun 10, 2024
@p0mvn p0mvn marked this pull request as draft June 10, 2024 19:39
Comment on lines -73 to +101
return handler(grpcCtx, req)
// Extract the existing span context from the incoming request
parentCtx := otel.GetTextMapPropagator().Extract(grpcCtx, propagation.HeaderCarrier(md))

// Start a new span representing the request
// The span ends when the request is complete
grpcCtx, span := tracer.Start(parentCtx, grpcInfo.FullMethod, trace.WithSpanKind(trace.SpanKindServer))
defer span.End()

span.SetAttributes(attribute.String("http.method", grpcInfo.FullMethod))

resp, err = handler(grpcCtx, req)

if err != nil {
span.SetStatus(otelcodes.Error, err.Error())
} else {
span.SetStatus(otelcodes.Ok, "OK")
}

return resp, err
Copy link
Member Author

Choose a reason for hiding this comment

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

Link

version: v1.51.2
version: v1.54.0
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to do this because this is the first version that supports go 1.21

@@ -8,7 +8,6 @@ run:
linters:
disable-all: true
enable:
- depguard
Copy link
Member Author

Choose a reason for hiding this comment

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

note: too many complaints after linter version bump so I removed it

@p0mvn p0mvn marked this pull request as ready for review July 21, 2024 00:15
@p0mvn p0mvn merged commit 5c3a933 into osmo/v0.47.5 Jul 22, 2024
23 checks passed
@p0mvn p0mvn deleted the roman/otel-wiring branch July 22, 2024 18:31
@p0mvn p0mvn restored the roman/otel-wiring branch July 23, 2024 01:09
mergify bot pushed a commit that referenced this pull request Jul 23, 2024
* OTEL wiring in grpcserver

* updates

* updates

* grpc headers

* updates

* updates

* updates

* go 1.21

* updates

* test go1.21

* update lint go

* go mod for tests

* more updates

* bump linter version

* updates

* remove nakedret

* codeql go version

(cherry picked from commit 5c3a933)

# Conflicts:
#	.github/workflows/lint.yml
#	.golangci.yml
#	baseapp/grpcserver.go
#	go.mod
#	go.sum
#	simapp/go.mod
#	simapp/go.sum
#	tests/go.mod
#	tests/go.sum
p0mvn added a commit that referenced this pull request Jul 23, 2024
* OTEL wiring in grpcserver

* updates

* updates

* grpc headers

* updates

* updates

* updates

* go 1.21

* updates

* test go1.21

* update lint go

* go mod for tests

* more updates

* bump linter version

* updates

* remove nakedret

* codeql go version
p0mvn added a commit that referenced this pull request Jul 23, 2024
) (#619)

* OTEL wiring in grpcserver interceptor (DataDog POC) (backport #612)

* updates

* deps

* updates

* updates

* updates

* updates

* lint

---------

Co-authored-by: Roman <roman@osmosis.team>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants