Skip to content

proposal: Extracting/injecting trace info from/to headers#24

Merged
danslapman merged 1 commit intoleviysoft:mainfrom
ashashev:chore/extract-inject-trace-info
Dec 14, 2023
Merged

proposal: Extracting/injecting trace info from/to headers#24
danslapman merged 1 commit intoleviysoft:mainfrom
ashashev:chore/extract-inject-trace-info

Conversation

@ashashev
Copy link
Copy Markdown
Contributor

@ashashev ashashev commented Nov 4, 2023

Adding extracting tracing info from headers of HTTP and gRPC calls and adding them to response headers.

The configuration example:

{
    "tracing": {
      "required": ["correlationId", "traceId"],
      "incomingHeaders": {
        "X-Trace-ID": "traceId",
        "X-Request-ID": "traceId"
      },
      "outcomingHeaders": {
        "correlationId": "X-Correlation-ID",
        "traceId": "X-Trace-ID"
      }
    }
}

The required field contains the list of obligated tracing fields. These fields always exist, it means when a client calls, the mockingbird generates for these fields unique ID (UUID).

The incomingHeaders set matching between request headers that contain tracing info and tracing field on the Mockingbird side. Comparing the headers is case-insensitive. For the config above, if request contains "X-Trace-ID" or "X-Request-ID", its value overrides generated value of traceId field.

The outcomingHeaders specified which tracing fields should be returned in response headers.

@mockingbird/maintainers

@ashashev ashashev changed the title Extracting/injecting trace info from/to headers proposal: Extracting/injecting trace info from/to headers Nov 4, 2023
@ashashev ashashev force-pushed the chore/extract-inject-trace-info branch from 753cf28 to f724828 Compare December 2, 2023 21:09
@ashashev ashashev marked this pull request as draft December 5, 2023 21:18
@ashashev ashashev force-pushed the chore/extract-inject-trace-info branch from f724828 to 3fed19a Compare December 5, 2023 21:41
@ashashev ashashev marked this pull request as ready for review December 6, 2023 17:29

object GrpcRequestHandler {
object keys {
val correlationId = io.grpc.Metadata.Key.of("X-Correlation-ID", io.grpc.Metadata.ASCII_STRING_MARSHALLER)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think these fields should be configurable as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I will add separate config for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, it's from previous changes. It is not actual for now. I misunderstood you. Now HTTP and gRPC have the same configuration, see file backend/mockingbird/src/main/scala/ru/tinkoff/tcb/mockingbird/api/Tracing.scala line 20. So, I will delete object keys, because it is unused.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, tracing for gRPC and HTTP have the same configuration. If you think that adding the separate config for extracting/injecting gRPC I will do it.

Copy link
Copy Markdown
Member

@danslapman danslapman left a comment

Choose a reason for hiding this comment

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

GRPC headers should be configurable as well

@ashashev ashashev marked this pull request as draft December 11, 2023 22:08
@ashashev ashashev force-pushed the chore/extract-inject-trace-info branch from 3fed19a to ab1b54f Compare December 13, 2023 18:51
@ashashev ashashev marked this pull request as ready for review December 13, 2023 19:00
Copy link
Copy Markdown
Member

@danslapman danslapman left a comment

Choose a reason for hiding this comment

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

LGTM

Adding extracting tracing info from headers of HTTP and gRPC calls and
adding them to response headers.

The configuration example:

```
{
    "tracing": {
      "required": ["correlationId", "traceId"],
      "incomingHeaders": {
        "X-Trace-ID": "traceId",
        "X-Request-ID": "traceId"
      },
      "outcomingHeaders": {
        "correlationId": "X-Correlation-ID",
        "traceId": "X-Trace-ID"
      }
    }
}
```

The required field contains the list of obligated tracing fields.
These fields always exist, it means when a client calls, the
mockingbird generates for these fields unique ID (UUID).

The incomingHeaders set matching between request headers that contain
tracing info and tracing field on the Mockingbird side. Comparing the
headers is case-insensitive. For the config above, if request contains
"X-Trace-ID" or "X-Request-ID", its value overrides generated value of
traceId field.

The outcomingHeaders specified which tracing fields should be returned
in response headers.
@ashashev ashashev force-pushed the chore/extract-inject-trace-info branch from 7825248 to 2067157 Compare December 14, 2023 21:33
@danslapman danslapman merged commit b7c00e6 into leviysoft:main Dec 14, 2023
@ashashev ashashev deleted the chore/extract-inject-trace-info branch December 15, 2023 06:14
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