Skip to content

Commit

Permalink
config: add OTLP configuration types
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <[email protected]>
  • Loading branch information
hdonnay committed Sep 25, 2023
1 parent eb54b88 commit 5995c03
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 25 deletions.
95 changes: 89 additions & 6 deletions Documentation/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ The output of that command is also not currently suitable to be used to "compile
[rfc7386]: https://datatracker.ietf.org/doc/html/rfc7386
[rfc6902]: https://datatracker.ietf.org/doc/html/rfc6902

## Configuration Reference
## Deprecations and Changes

Please see the [go module documentation][godoc_config] for additional documentation on defaults and use.
Starting in version `4.7.0`, unknown keys are disallowed.
Configurations that looked valid previously and loaded fine may now cause Clair to refuse to start.

In version `4.8.0`, using Jaeger for trace submission was deprecated.
Configurations that use Jaeger will print a warning.
In future versions, using Jaeger may cause an error.

## Configuration Reference

Please see the [go module documentation][godoc_config] for additional documentation on defaults and use.

[godoc_config]: https://pkg.go.dev/github.com/quay/clair/config

```
Expand Down Expand Up @@ -121,6 +128,9 @@ trace:
service_name: ""
tags: nil
buffer_max: 0
otlp:
http: {}
grpc: {}
metrics:
name: ""
prometheus:
Expand All @@ -140,6 +150,7 @@ more information.
# `$.auth.keyserver`
# `$.auth.keyserver.api`
# `$.auth.keyserver.intraservice`
# `$.metrics.otlp`
-->

### `$.http_listen_addr`
Expand Down Expand Up @@ -599,18 +610,21 @@ JWT claim.
Defines distributed tracing configuration based on OpenTelemetry.

#### `$.trace.name`
a string value

The name of the application traces will belong to.
Which submission format to use, one of:
- jaeger
- otlp

#### `$.trace.probability`
a float value

The probability a trace will occur.

#### `$.trace.jaeger`
### `$.trace.jaeger`
Defines values for Jaeger tracing.

***NOTE***: Jaeger has deprecated using the `jaeger` protocol and encouraging users to migrate to OTLP,
which Jaeger can ingest natively.

#### `$.trace.jaeger.agent`
Defines values for configuring delivery to a Jaeger agent.

Expand Down Expand Up @@ -642,6 +656,75 @@ a mapping of a string to a string
#### `$.trace.jaeger.buffer_max`
an integer value

### `$.trace.otlp`
Configuration for OTLP traces.

Only one of the `http` or `grpc` keys should be provided.

#### `$.trace.otlp.http`
Configuration for OTLP traces submitted by HTTP.

##### `$.trace.otlp.http.url_path`
Request path to use for submissions.
Defaults to `/v1/traces`.

##### `$.trace.otlp.http.compression`
Compression for payloads.
One of:
- gzip
- none

##### `$.trace.otlp.http.endpoint`
`Host:port` for submission. Defaults to `localhost:4318`.

##### `$.trace.otlp.http.headers`
Key-value pairs of additional headers for submissions.

##### `$.trace.otlp.http.insecure`
Use HTTP instead of HTTPS.

##### `$.trace.otlp.http.timeout`
Maximum of of time for a trace submission.

##### `$.trace.otlp.http.client_tls.cert`
Client certificate for connection.

##### `$.trace.otlp.http.client_tls.key`
Key for the certificate specified in `cert`.

#### `$.trace.otlp.grpc`
Configuration for OTLP traces submitted by gRPC.

##### `$.trace.otlp.grpc.reconnect`
Sets the minimum time between connection attempts.

##### `$.trace.otlp.grpc.service_config`
A string containing a JSON-format gRPC service config.

##### `$.trace.otlp.grpc.compression`
Compression for payloads.
One of:
- gzip
- none

##### `$.trace.otlp.grpc.endpoint`
`Host:port` for submission. Defaults to `localhost:4317`.

##### `$.trace.otlp.grpc.headers`
Key-value pairs of additional headers for submissions.

##### `$.trace.otlp.grpc.insecure`
Do not verify the server certificate.

##### `$.trace.otlp.grpc.timeout`
Maximum of of time for a trace submission.

##### `$.trace.otlp.grpc.client_tls.cert`
Client certificate for connection.

##### `$.trace.otlp.grpc.client_tls.key`
Key for the certificate specified in `cert`.

### `$.metrics`
Defines distributed tracing configuration based on OpenTelemetry.

Expand Down
7 changes: 4 additions & 3 deletions config/doc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Package config is the configuration package for Clair's binaries. See the
// Config type for the main entry point.
// [Config] type for the main entry point.
//
// It's currently meant for reading configs and tested against YAML and JSON.
// It's currently meant for reading configurations and tested against YAML and
// JSON.
//
// # Version Scheme
//
Expand All @@ -16,7 +17,7 @@
// changes on a program importing the module.
package config

// This pakcage can't use "omitempty" tags on slices because "not present" and
// This package can't use "omitempty" tags on slices because "not present" and
// "empty" aren't distinguished. This would be much easier if code didn't
// serialize our config struct. It's impossible to implement custom YAML
// marshalling without importing the yaml.v3 package.
29 changes: 21 additions & 8 deletions config/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import "fmt"
// Trace specifies how to configure Clair's tracing support.
//
// The "Name" key must match the provider to use.
//
// Currently, only "jaeger" is supported.
type Trace struct {
Name string `yaml:"name" json:"name"`
Probability *float64 `yaml:"probability,omitempty" json:"probability,omitempty"`
Jaeger Jaeger `yaml:"jaeger,omitempty" json:"jaeger,omitempty"`
Name string `yaml:"name" json:"name"`
Probability *float64 `yaml:"probability,omitempty" json:"probability,omitempty"`
Jaeger Jaeger `yaml:"jaeger,omitempty" json:"jaeger,omitempty"`
OTLP TraceOTLP `yaml:"otlp,omitempty" json:"otlp,omitempty"`
}

func (t *Trace) lint() ([]Warning, error) {
switch t.Name {
case "":
case "otlp":
case "jaeger":
return []Warning{{
path: ".name",
msg: `trace provider "jaeger" is deprecated; migrate to "otlp"`,
}}, nil
default:
return []Warning{{
path: ".name",
Expand All @@ -27,6 +31,11 @@ func (t *Trace) lint() ([]Warning, error) {
}

// Jaeger specific distributed tracing configuration.
//
// Deprecated: The Jaeger project recommends using their OTLP ingestion support
// and the OpenTelemetry exporter for Jaeger has since been removed. Users
// should migrate to OTLP. Clair may refuse to start when configured to emit
// Jaeger traces.
type Jaeger struct {
Tags map[string]string `yaml:"tags,omitempty" json:"tags,omitempty"`
Agent struct {
Expand All @@ -44,16 +53,20 @@ type Jaeger struct {
// Metrics specifies how to configure Clair's metrics exporting.
//
// The "Name" key must match the provider to use.
//
// Currently, only "prometheus" is supported.
type Metrics struct {
Prometheus Prometheus `yaml:"prometheus,omitempty" json:"prometheus,omitempty"`
Name string `yaml:"name" json:"name"`
Prometheus Prometheus `yaml:"prometheus,omitempty" json:"prometheus,omitempty"`
OTLP MetricOTLP `yaml:"otlp,omitempty" json:"otlp,omitempty"`
}

func (m *Metrics) lint() ([]Warning, error) {
switch m.Name {
case "":
case "otlp":
return []Warning{{
path: ".name",
msg: `please consult the documentation for the status of metrics via "otlp"`,
}}, nil
case "prometheus":
default:
return []Warning{{
Expand Down
Loading

0 comments on commit 5995c03

Please sign in to comment.