Once the OpenTelemetry SDK has created and processed telemetry, it needs to be exported. This package contains exporters for this purpose.
The following exporter packages are provided with the following OpenTelemetry signal support.
Exporter Package | Logs |
---|---|
github.com/agoda-com/opentelemetry-logs-go/exporters/otlp/otlplogs | ✓ |
github.com/agoda-com/opentelemetry-logs-go/exporters/stdout | ✓ |
Regarding specification
otlp exporter implemented otlplogsgrpc
and otlplogshttp
clients with next protocols
supported: gprc
, http/protobuf
and http/json
.
If client is not configured explicitly ,The OTEL_EXPORTER_OTLP_PROTOCOL
, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL
environment variables specify the OTLP transport protocol. Supported values:
grpc
for protobuf-encoded data using gRPC wire format over HTTP/2 connectionhttp/protobuf
for protobuf-encoded data over HTTP connectionhttp/json
for JSON-encoded data over HTTP connection
package main
func main() {
ctx := context.Background()
exporter, _ := otlplogs.NewExporter(ctx) // will create exporter with http client `http/protobuf` protocol by default
}
Use OTEL_EXPORTER_OTLP_PROTOCOL=grpc
env configuration or specify http client explicitly:
exporter, _ := otlplogs.NewExporter(ctx, otlplogs.WithClient(otlplogsgrpc.NewClient()))
Use OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
env configuration or specify http client explicitly:
exporter, _ := otlplogs.NewExporter(ctx, otlplogs.WithClient(otlplogshttp.NewClient(otlplogshttp.WithProtobufProtocol())))
Use OTEL_EXPORTER_OTLP_PROTOCOL=http/json
env configuration or specify http client explicitly:
exporter, _ := otlplogs.NewExporter(ctx, otlplogs.WithClient(otlplogshttp.NewClient(otlplogshttp.WithJsonProtocol())))
The logging exporter prints the name of the log along with its attributes to stdout. It's mainly used for testing and debugging.
exporter, _ := stdoutlogs.NewExporter(ctx)