Skip to content

ref(grpc): migrate server to context scope API - #1404

Open
giortzisg wants to merge 1 commit into
scopes/fiber-fasthttp-integrationsfrom
scopes/grpc-server-integration
Open

giortzisg wants to merge 1 commit into
scopes/fiber-fasthttp-integrationsfrom
scopes/grpc-server-integration

Conversation

@giortzisg

Copy link
Copy Markdown
Contributor

Description

This migrates the grpc integration to use the new scopes API.

Issues

Changelog Entry Instructions

To add a custom changelog entry, uncomment the section above. Supports:

  • Single entry: just write text
  • Multiple entries: use bullet points
  • Nested bullets: indent 4+ spaces

For more details: custom changelog entries

Reminders

Stack created with GitHub Stacks CLIGive Feedback 💬

@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from 5259ffd to ef993c6 Compare September 1, 2026 09:13
Comment thread grpc/server.go Outdated
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from ef993c6 to 5db9c0c Compare September 1, 2026 12:22
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from 5db9c0c to 3f56f8c Compare September 1, 2026 12:58
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from 3f56f8c to 220e329 Compare September 2, 2026 07:59
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch 2 times, most recently from 953c46a to 6f348e2 Compare September 4, 2026 13:26
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from 6f348e2 to fe9727e Compare September 7, 2026 11:40
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from fe9727e to d5377ce Compare September 7, 2026 11:50
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from d5377ce to a851dce Compare September 16, 2026 09:14
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from a851dce to 583b5dd Compare September 17, 2026 08:38
Comment thread grpc/server.go
Carry isolated scopes through RPC contexts for tracing, capture, request metadata, and panic handling. Continue traces from every incoming baggage metadata value.

Preserve caller context values and active child spans when a gateway transaction already exists. Only the interceptor that creates a transaction writes RPC metadata and status or finishes it, for both unary and streaming calls.
@giortzisg
giortzisg force-pushed the scopes/grpc-server-integration branch from 583b5dd to a40929e Compare September 17, 2026 09:09
Comment thread grpc/server.go
Comment on lines +88 to +91
if service != "" {
transaction.SetData("rpc.service", service)
}
if method != "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: When a parent span exists, a new transaction is created but not added to the context or finished, leading to lost child span data.
Severity: MEDIUM

Suggested Fix

When owned == false, avoid creating a new, orphaned transaction. The logic should either retrieve and use the existing transaction from the parent context or, if a new transaction is strictly necessary, ensure it is properly finished. The current implementation, which creates and then discards a transaction without finishing it, should be corrected to prevent data loss.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: grpc/server.go#L88-L91

Potential issue: In the `startServerTransaction` function, when a parent span already
exists (the `owned == false` case), a new transaction is created but is never finished,
nor is it added to the context returned to the handler. This creates an inconsistent
state. If the handler or subsequent logic creates child spans using this new, unfinished
`transaction` object, those child spans are recorded but will never be sent to Sentry
because their parent transaction is never completed. This results in silently lost
tracing data for nested operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants