Skip to content

Commit

Permalink
Merge pull request #247 from movio/opentelemetry
Browse files Browse the repository at this point in the history
feat: OpenTelemetry env url
  • Loading branch information
asger-noer authored Jan 21, 2024
2 parents deb663b + 6ea435c commit 8950960
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 8950960

Please sign in to comment.