github.com/icyphox/x@v0.0.355-0.20220311094250-029bd783e8b8/tracing/config.go (about)

     1  package tracing
     2  
     3  import (
     4  	"bytes"
     5  	_ "embed"
     6  	"io"
     7  )
     8  
     9  // JaegerConfig encapsulates jaeger's configuration.
    10  type JaegerConfig struct {
    11  	LocalAgentAddress string          `json:"local_agent_address"`
    12  	Sampling          *JaegerSampling `json:"sampling"`
    13  	Propagation       string          `json:"propagation"`
    14  	MaxTagValueLength int             `json:"max_tag_value_length"`
    15  }
    16  
    17  type JaegerSampling struct {
    18  	Type      string  `json:"type"`
    19  	Value     float64 `json:"value"`
    20  	ServerURL string  `json:"server_url"`
    21  }
    22  
    23  // ZipkinConfig encapsulates zipkin's configuration.
    24  type ZipkinConfig struct {
    25  	ServerURL string `json:"server_url"`
    26  }
    27  
    28  type Config struct {
    29  	ServiceName string           `json:"service_name"`
    30  	Provider    string           `json:"provider"`
    31  	Providers   *ProvidersConfig `json:"providers"`
    32  }
    33  
    34  type ProvidersConfig struct {
    35  	Jaeger *JaegerConfig `json:"jaeger"`
    36  	Zipkin *ZipkinConfig `json:"zipkin"`
    37  }
    38  
    39  //go:embed config.schema.json
    40  var ConfigSchema string
    41  
    42  const ConfigSchemaID = "ory://tracing-config"
    43  
    44  // AddConfigSchema adds the tracing schema to the compiler.
    45  // The interface is specified instead of `jsonschema.Compiler` to allow the use of any jsonschema library fork or version.
    46  func AddConfigSchema(c interface {
    47  	AddResource(url string, r io.Reader) error
    48  }) error {
    49  	return c.AddResource(ConfigSchemaID, bytes.NewBufferString(ConfigSchema))
    50  }