Skip to content

Commit

Permalink
feat: add deployment.environment attribute to OTEL data (CORE-2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
splaunov committed Aug 4, 2023
1 parent e9342cd commit faabee2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions configx/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,9 @@ func (p *Provider) CORS(prefix string, defaults cors.Options) (cors.Options, boo

func (p *Provider) TracingConfig(serviceName string) *otelx.Config {
return &otelx.Config{
ServiceName: p.StringF("tracing.service_name", serviceName),
Provider: p.String("tracing.provider"),
ServiceName: p.StringF("tracing.service_name", serviceName),
DeploymentEnvironment: p.StringF("tracing.deployment_environment", ""),
Provider: p.String("tracing.provider"),
Providers: otelx.ProvidersConfig{
Jaeger: otelx.JaegerConfig{
Sampling: otelx.JaegerSampling{
Expand Down
7 changes: 4 additions & 3 deletions otelx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ type ProvidersConfig struct {
}

type Config struct {
ServiceName string `json:"service_name"`
Provider string `json:"provider"`
Providers ProvidersConfig `json:"providers"`
ServiceName string `json:"service_name"`
DeploymentEnvironment string `json:"deployment_environment"`
Provider string `json:"provider"`
Providers ProvidersConfig `json:"providers"`
}

//go:embed config.schema.json
Expand Down
5 changes: 5 additions & 0 deletions otelx/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"description": "Specifies the service name to use on the tracer.",
"examples": ["Ory Hydra", "Ory Kratos", "Ory Keto", "Ory Oathkeeper"]
},
"deployment_environment": {
"type": "string",
"description": "Specifies the deployment environment to use on the tracer.",
"examples": ["development", "staging", "production"]
},
"providers": {
"type": "object",
"additionalProperties": false,
Expand Down
1 change: 1 addition & 0 deletions otelx/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func SetupOTLP(t *Tracer, tracerName string, c *Config) (trace.Tracer, error) {
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(c.ServiceName),
semconv.DeploymentEnvironmentKey.String(c.DeploymentEnvironment),
)),
sdktrace.WithSampler(sdktrace.ParentBased(sdktrace.TraceIDRatioBased(
c.Providers.OTLP.Sampling.SamplingRatio,
Expand Down

0 comments on commit faabee2

Please sign in to comment.