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

Make it vendor agnostic in the configurations and environment variables #68

Open
pragmaticivan opened this issue Dec 4, 2021 · 1 comment

Comments

@pragmaticivan
Copy link

pragmaticivan commented Dec 4, 2021

Is your feature request related to a problem? Please describe.
This project is really awesome and might be worth making it vendor-agnostic with optional authentication and support for sending data to otel collector.

Describe the solution you'd like
Add a few new configs:

  • AuthEnabled bool
  • AuthAccessTokenHeader string
  • Default SPAN_ENDPOINT to otel collector (localhost)
  • Derive ACCESS_TOKEN env var from config name.

Additional context
The usage for other vendors is pretty similar but this lib makes it way less complicated. Worth making it generic and perhaps donating that to cncf org one day?

@pragmaticivan pragmaticivan changed the title Make it vendor agnostic Make it vendor agnostic in the configurations and environment variables Dec 5, 2021
@pragmaticivan
Copy link
Author

I have a working version of that change:

type Config struct {
	SpanExporterEndpoint           string            `env:"OTEL_EXPORTER_OTLP_SPAN_ENDPOINT,default=0.0.0.0:4317"`
	SpanExporterEndpointInsecure   bool              `env:"OTEL_EXPORTER_OTLP_SPAN_INSECURE,default=false"`
	ServiceName                    string            `env:"SERVICE_NAME"`
	ServiceVersion                 string            `env:"SERVICE_VERSION,default=unknown"`
	Headers                        map[string]string `env:"OTEL_EXPORTER_OTLP_HEADERS"`
	MetricExporterEndpoint         string            `env:"OTEL_EXPORTER_OTLP_METRIC_ENDPOINT,default=0.0.0.0:4317"`
	MetricExporterEndpointInsecure bool              `env:"OTEL_EXPORTER_OTLP_METRIC_INSECURE,default=false"`
	MetricsEnabled                 bool              `env:"METRICS_ENABLED,default=true"`
	LogLevel                       string            `env:"OTEL_LOG_LEVEL,default=info"`
	Propagators                    []string          `env:"OTEL_PROPAGATORS,default=b3"`
	MetricReportingPeriod          string            `env:"OTEL_EXPORTER_OTLP_METRIC_PERIOD,default=30s"`
	AuthEnabled                    bool              `env:"AUTH_ENABLED,default=true"`
	AuthAccessTokenHeader          string            `env:"AUTH_ACCESS_TOKEN_HEADER,default=api-key"`
	ResourceAttributes             map[string]string
	Resource                       *resource.Resource
	logger                         Logger
	errorHandler                   otel.ErrorHandler
}

Usage with another vendor:

otelLauncher := otel.ConfigureOpentelemetry(
		otel.WithAuthAccessTokenHeader("api-key"),
		otel.WithServiceName("app-name"),
		otel.WithMetricExporterEndpoint("otlp.nr-data.net:4317"),
		otel.WithSpanExporterEndpoint("otlp.nr-data.net:4317"),
		otel.WithAccessToken("my-token"),
		otel.WithMetricsEnabled(true),
		otel.WithMetricReportingPeriod(time.Second*5)
	)

It could still default to light step *_ENDPOINT and perhaps lightstep-access-token in the token header

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

No branches or pull requests

1 participant