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

[feature] add support for sending headers to tracing system #3604

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joschi
Copy link

@joschi joschi commented Dec 7, 2024

Description

Add support for sending additional HTTP or gRPC headers which can be used for authentication or other additional information for the tracing system without having to set up a local instance of the OpenTelemetry Collector to add these headers.

Example with Dash0:

tracing-enabled: false
tracing-transport: "grpc"
tracing-endpoint: "ingress.eu-west-1.aws.dash0.com:4317"
tracing-headers:
  "Authorization": "Bearer DASH0_AUTH_TOKEN"
  "Dash0-Dataset": "gotosocial"

Example with Honeycomb:

tracing-enabled: false
tracing-transport: "grpc"
tracing-endpoint: "api.honeycomb.io:443"
tracing-headers:
  "x-honeycomb-team": "YOUR_API_KEY"
  "x-honeycomb-dataset": "YOUR_DATASET"

refs #1230

See also https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/[email protected]#WithHeaders.

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@@ -31,6 +31,11 @@ tracing-transport: "grpc"
# 默认值: ""
tracing-endpoint: ""

# TODO
Copy link
Author

Choose a reason for hiding this comment

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

note: help would be appreciated here for a proper translation.

@tsmethurst
Copy link
Contributor

Oh this looks interesting! :)

@joschi joschi force-pushed the feature-otel-headers branch from e69716f to 1e4fd0b Compare December 8, 2024 19:51
@joschi joschi marked this pull request as ready for review December 10, 2024 10:17
@joschi joschi force-pushed the feature-otel-headers branch from 1e4fd0b to ee5bc14 Compare December 10, 2024 10:17
@daenney
Copy link
Member

daenney commented Dec 14, 2024

I actually wonder if we shouldn't just tell people to use the OTLP environment variables instead. Otherwise we're going to have to add configuration options over time for anything the SDK already supports.

For example, you could set those values already with OTEL_EXPORTER_OTLP_TRACES_HEADERS and they should get picked up. By explicitly using WithHeaders we actually disable that facility.

I'm not entirely sure where to draw the line with this. Realistically, we can remove the tracing-* config options entirely since everything we have can already be done using the OTLP_* environment variables.

Add support for sending additional HTTP or gRPC headers which
can be used for authentication or other additional information
for the tracing system without having to set up a local instance
of the OpenTelemetry Collector to add these headers.

Example with Dash0:

```yaml
tracing-enabled: false
tracing-transport: "grpc"
tracing-endpoint: "ingress.eu-west-1.aws.dash0.com:4317"
tracing-headers:
  "Authorization": "Bearer DASH0_AUTH_TOKEN"
  "Dash0-Dataset": "gotosocial"
```

Example with Honeycomb:

```yaml
tracing-enabled: false
tracing-transport: "grpc"
tracing-endpoint: "api.honeycomb.io:443"
tracing-headers:
  "x-honeycomb-team": "YOUR_API_KEY"
  "x-honeycomb-dataset": "YOUR_DATASET"
```
Maps are currently not supported in environment variables.

See also spf13/viper#339
```
go run ./internal/config/gen/ -out ./internal/config/helpers.gen.go
```
@joschi joschi force-pushed the feature-otel-headers branch from a18573b to 6c013c2 Compare December 14, 2024 16:28
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.

3 participants