Skip to content

feat: add subgraph expressions and tracing attributes #1870

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

Merged
merged 8 commits into from
May 23, 2025

Conversation

SkArchon
Copy link
Contributor

@SkArchon SkArchon commented May 19, 2025

Motivation and Context

This PR adds subgraph expressions and tracing attributes.

Subgraph ExpressionContext
The following is introduced. We only have a minimal expression context for subgraph as it stands. We introduce the following

subgraph:
  id # subgraph id
  name #subgraph name
  request
    error #subgraph error if any occurred
    clientTrace # we can add any future trace related params here without polluting the request interface
      connAcquireDuration

Add Tracing Attributes
We already have metric and telemetry attributes, however we do not have tracing attributes, which can only be used to add values to tracing or spans. This is introduced as customers might be interested in how long a connectionAcquire took for a subgraph.

Process subgraph expressions for telemetry
Like we have attributesWithAuth we introduce attributesWithSubgraph which is essentially attributes that use subgraph in the expression context. We separate these values out for all three of telemetry / tracing and metric attributes and process them for every subgraph call.

Process Subgraph Expressions In Logs And Tracing/Telemetry Attributes
We have expressions for router access logs, however we do not use expressions for the subgraph access logger right now, we add this feature and allow users to define subgraph access log expressions.

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.

@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch from a570bac to 6350075 Compare May 19, 2025 22:15
Copy link

github-actions bot commented May 19, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-477e5356821a4b564e82d897835ac543641a4027

@SkArchon SkArchon changed the title feat: Add subgraph expressions and tracing attributes feat: add subgraph expressions and tracing attributes May 20, 2025
@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch from 5f7840c to 5b415f0 Compare May 20, 2025 11:35
@SkArchon SkArchon marked this pull request as ready for review May 20, 2025 12:02
@SkArchon SkArchon requested a review from StarpTech May 20, 2025 18:32
Copy link
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch 2 times, most recently from 65858c3 to 7780ccc Compare May 22, 2025 12:00
Base automatically changed from milinda/trace-new-metrics to main May 22, 2025 17:37
@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch 2 times, most recently from 66fe110 to 683b33c Compare May 22, 2025 18:09
@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch from 683b33c to 4f33f09 Compare May 22, 2025 18:15
@SkArchon SkArchon force-pushed the milinda/subgraph-expr-logging branch from 21fcaba to a8cfb06 Compare May 23, 2025 08:20
@SkArchon SkArchon merged commit 368fa20 into main May 23, 2025
24 checks passed
@SkArchon SkArchon deleted the milinda/subgraph-expr-logging branch May 23, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants