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

feat: OpenTelemetry env url #247

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Sample configuration:
- Default: `false`
- Supports hot-reload: No
- `endpoint`: OpenTelemetry collector endpoint.
- Default: If no endpoint is specified, telemetry is disabled.
- Default: If no endpoint is specified, telemetry is disabled. Bramble will check for `BRAMBLE_OTEL_ENDPOINT` environment variable and use it if set.
- Supports hot-reload: No
- `serviceName`: Service name to use for OpenTelemetry.
- Default: `bramble`
Expand Down
6 changes: 6 additions & 0 deletions telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bramble
import (
"context"
"errors"
"os"

"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -41,6 +42,11 @@ func (e *TelemetryErrHandler) Handle(err error) {
// returns a shutdown function that should be called when the application
// terminates.
func InitTelemetry(ctx context.Context, cfg TelemetryConfig) (func(context.Context) error, error) {
endpoint := os.Getenv("BRAMBLE_OTEL_ENDPOINT")
if endpoint != "" {
cfg.Endpoint = endpoint
}

// If telemetry is disabled, return a no-op shutdown function. The standard
// behaviour of the application will not be affected, since a
// `NoopTracerProvider` is used by default.
Expand Down
Loading