Skip to content

Commit

Permalink
Refactor otlp exporter (#146)
Browse files Browse the repository at this point in the history
* Refactor OTLP exporters to make protocol explicit

* Revert using allOf

* proto -> protobuf
  • Loading branch information
jack-berg authored Jan 13, 2025
1 parent bbe4bf1 commit 588a82d
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 137 deletions.
152 changes: 129 additions & 23 deletions examples/kitchen-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ logger_provider:
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
endpoint: http://localhost:4318/v1/logs
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand All @@ -72,7 +68,43 @@ logger_provider:
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .protocol is grpc and .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# Configure the encoding used for messages. Values include: protobuf, json. Implementations may not support json.
# If omitted or null, protobuf is used.
encoding: protobuf
- # Configure a batch log record processor.
batch:
# Configure exporter.
exporter:
# Configure exporter to be OTLP with gRPC transport.
otlp_grpc:
# Configure endpoint.
# If omitted or null, http://localhost:4317 is used.
endpoint: http://localhost:4317
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
certificate: /app/cert.pem
# Configure mTLS private client key. Absolute path to client key in PEM format. If set, .client_certificate must also be set.
# If omitted or null, mTLS is not used.
client_key: /app/cert.pem
# Configure mTLS client certificate. Absolute path to certificate file. If set, .client_key must also be set.
# If omitted or null, mTLS is not used.
client_certificate: /app/cert.pem
# Configure headers. Entries have higher priority than entries from .headers_list.
# If an entry's .value is null, the entry is ignored.
headers:
- name: api-key
value: "1234"
# Configure headers. Entries have lower priority than entries from .headers.
# The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details.
# If omitted or null, no headers are added.
headers_list: "api-key=1234"
# Configure compression. Values include: gzip, none. Implementations may support other compression algorithms.
# If omitted or null, none is used.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# If omitted or null, false is used.
insecure: false
- # Configure a simple log record processor.
Expand Down Expand Up @@ -145,12 +177,10 @@ meter_provider:
timeout: 30000
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the metric specific path.
# If omitted or null, http://localhost:4318/v1/metrics is used.
endpoint: http://localhost:4318/v1/metrics
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand All @@ -176,9 +206,9 @@ meter_provider:
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .protocol is grpc and .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# If omitted or null, false is used.
insecure: false
# Configure the encoding used for messages. Values include: protobuf, json. Implementations may not support json.
# If omitted or null, protobuf is used.
encoding: protobuf
# Configure temporality preference. Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md.
# If omitted or null, cumulative is used.
temporality_preference: delta
Expand All @@ -189,6 +219,48 @@ meter_provider:
producers:
- # Configure metric producer to be prometheus.
prometheus:
- # Configure a periodic metric reader.
periodic:
# Configure exporter.
exporter:
# Configure exporter to be OTLP with gRPC transport.
otlp_grpc:
# Configure endpoint.
# If omitted or null, http://localhost:4317 is used.
endpoint: http://localhost:4317
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
certificate: /app/cert.pem
# Configure mTLS private client key. Absolute path to client key in PEM format. If set, .client_certificate must also be set.
# If omitted or null, mTLS is not used.
client_key: /app/cert.pem
# Configure mTLS client certificate. Absolute path to certificate file. If set, .client_key must also be set.
# If omitted or null, mTLS is not used.
client_certificate: /app/cert.pem
# Configure headers. Entries have higher priority than entries from .headers_list.
# If an entry's .value is null, the entry is ignored.
headers:
- name: api-key
value: "1234"
# Configure headers. Entries have lower priority than entries from .headers.
# The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details.
# If omitted or null, no headers are added.
headers_list: "api-key=1234"
# Configure compression. Values include: gzip, none. Implementations may support other compression algorithms.
# If omitted or null, none is used.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# If omitted or null, false is used.
insecure: false
# Configure temporality preference. Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md.
# If omitted or null, cumulative is used.
temporality_preference: delta
# Configure default histogram aggregation. Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md.
# If omitted or null, explicit_bucket_histogram is used.
default_histogram_aggregation: base2_exponential_bucket_histogram
- # Configure a periodic metric reader.
periodic:
# Configure exporter.
Expand Down Expand Up @@ -293,12 +365,10 @@ tracer_provider:
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the trace specific path.
# If omitted or null, http://localhost:4318/v1/traces is used.
endpoint: http://localhost:4318/v1/traces
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand All @@ -324,7 +394,43 @@ tracer_provider:
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .protocol is grpc and .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# Configure the encoding used for messages. Values include: protobuf, json. Implementations may not support json.
# If omitted or null, protobuf is used.
encoding: protobuf
- # Configure a batch span processor.
batch:
# Configure exporter.
exporter:
# Configure exporter to be OTLP with gRPC transport.
otlp_grpc:
# Configure endpoint.
# If omitted or null, http://localhost:4317 is used.
endpoint: http://localhost:4317
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
certificate: /app/cert.pem
# Configure mTLS private client key. Absolute path to client key in PEM format. If set, .client_certificate must also be set.
# If omitted or null, mTLS is not used.
client_key: /app/cert.pem
# Configure mTLS client certificate. Absolute path to certificate file. If set, .client_key must also be set.
# If omitted or null, mTLS is not used.
client_certificate: /app/cert.pem
# Configure headers. Entries have higher priority than entries from .headers_list.
# If an entry's .value is null, the entry is ignored.
headers:
- name: api-key
value: "1234"
# Configure headers. Entries have lower priority than entries from .headers.
# The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details.
# If omitted or null, no headers are added.
headers_list: "api-key=1234"
# Configure compression. Values include: gzip, none. Implementations may support other compression algorithms.
# If omitted or null, none is used.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
# If omitted or null, 10000 is used.
timeout: 10000
# Configure client transport security for the exporter's connection. Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure.
# If omitted or null, false is used.
insecure: false
- # Configure a batch span processor.
Expand Down
28 changes: 10 additions & 18 deletions examples/sdk-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ tracer_provider:
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the trace specific path.
# If omitted or null, http://localhost:4318/v1/traces is used.
endpoint: http://localhost:4318/v1/traces
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down Expand Up @@ -145,12 +143,10 @@ meter_provider:
timeout: 30000
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the metric specific path.
# If omitted or null, http://localhost:4318/v1/metrics is used.
endpoint: http://localhost:4318/v1/metrics
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down Expand Up @@ -200,12 +196,8 @@ logger_provider:
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: http/protobuf
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
endpoint: http://localhost:4318/v1/logs
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down
30 changes: 11 additions & 19 deletions examples/sdk-migration-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# - OTEL_TRACES_EXPORTER
# - OTEL_METRICS_EXPORTER
# - OTEL_LOGS_EXPORTER
# - OTEL_EXPORTER_OTLP_PROTOCOL
# - OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_{SIGNAL}_PROTOCOL
# - OTEL_EXPORTER_OTLP_ENDPOINT
# - OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_{SIGNAL}_INSECURE
# - OTEL_EXPORTER_OTLP_CERTIFICATE
Expand Down Expand Up @@ -88,12 +88,10 @@ tracer_provider:
max_export_batch_size: ${OTEL_BSP_MAX_EXPORT_BATCH_SIZE:-512}
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: ${OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:-http/protobuf}
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the trace specific path.
# If omitted or null, http://localhost:4318/v1/traces is used.
endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces}
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down Expand Up @@ -184,12 +182,10 @@ meter_provider:
timeout: ${OTEL_METRIC_EXPORT_TIMEOUT:-30000}
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: ${OTEL_EXPORTER_OTLP_METRICS_PROTOCOL:-http/protobuf}
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
# Configure endpoint, including the metric specific path.
# If omitted or null, http://localhost:4318/v1/metrics is used.
endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics}
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down Expand Up @@ -243,12 +239,8 @@ logger_provider:
max_export_batch_size: ${OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:-512}
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol. Values include: http/protobuf, http/json, grpc.
protocol: ${OTEL_EXPORTER_OTLP_LOGS_PROTOCOL:-http/protobuf}
# Configure endpoint.
# If .protocol is http/protobuf or http/json, the signal specific path must be included (i.e. http://localhost:4318/v1/{signal}). If .protocol is grpc, a path should not be included (i.e. http://localhost:4317).
# Configure exporter to be OTLP with HTTP transport.
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs}
# Configure certificate. Absolute path to certificate file.
# If omitted or null, system default certificate verification is used for secure connections.
Expand Down
Loading

0 comments on commit 588a82d

Please sign in to comment.