github.com/icyphox/x@v0.0.355-0.20220311094250-029bd783e8b8/otelx/config.go (about) 1 package otelx 2 3 import ( 4 "bytes" 5 _ "embed" 6 "io" 7 ) 8 9 type JaegerConfig struct { 10 LocalAgentHost string `json:"local_agent_host"` 11 LocalAgentPort int `json:"local_agent_port"` 12 SamplingRatio float64 `json:"sampling_ratio"` 13 } 14 15 type ProvidersConfig struct { 16 Jaeger *JaegerConfig `json:"jaeger"` 17 } 18 19 type Config struct { 20 ServiceName string `json:"service_name"` 21 Provider string `json:"provider"` 22 Providers *ProvidersConfig `json:"providers"` 23 } 24 25 //go:embed config.schema.json 26 var ConfigSchema string 27 28 const ConfigSchemaID = "ory://tracing-config" 29 30 // AddConfigSchema adds the tracing schema to the compiler. 31 // The interface is specified instead of `jsonschema.Compiler` to allow the use of any jsonschema library fork or version. 32 func AddConfigSchema(c interface { 33 AddResource(url string, r io.Reader) error 34 }) error { 35 return c.AddResource(ConfigSchemaID, bytes.NewBufferString(ConfigSchema)) 36 }