-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add otlploggrpc exporter skeleton (#5246)
- Loading branch information
Showing
11 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# OTLP Log gRPC Exporter | ||
|
||
[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package otlploggrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc" | ||
|
||
type client struct { | ||
// TODO: implement. | ||
} | ||
|
||
// newClient creates a new gRPC log client. | ||
func newClient(cfg config) (*client, error) { | ||
// TODO: implement. | ||
return &client{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package otlploggrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc" | ||
|
||
import ( | ||
"time" | ||
|
||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials" | ||
) | ||
|
||
// Option applies an option to the Exporter. | ||
type Option interface { | ||
applyHTTPOption(config) config | ||
} | ||
|
||
type config struct { | ||
// TODO: implement. | ||
} | ||
|
||
func newConfig(options []Option) config { | ||
var c config | ||
for _, opt := range options { | ||
c = opt.applyHTTPOption(c) | ||
} | ||
return c | ||
} | ||
|
||
// RetryConfig defines configuration for retrying the export of log data | ||
// that failed. | ||
// | ||
// This configuration does not define any network retry strategy. That is | ||
// entirely handled by the gRPC ClientConn. | ||
type RetryConfig struct { | ||
// TODO: implement. | ||
} | ||
|
||
// WithInsecure disables client transport security for the Exporter's gRPC | ||
// connection, just like grpc.WithInsecure() | ||
// (https://pkg.go.dev/google.golang.org/grpc#WithInsecure) does. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | ||
// environment variable is set, and this option is not passed, that variable | ||
// value will be used to determine client security. If the endpoint has a | ||
// scheme of "http" or "unix" client security will be disabled. If both are | ||
// set, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT will take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, client security will be used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithInsecure() Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithEndpoint sets the target endpoint the Exporter will connect to. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | ||
// environment variable is set, and this option is not passed, that variable | ||
// value will be used. If both are set, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | ||
// will take precedence. | ||
// | ||
// If both this option and WithEndpointURL are used, the last used option will | ||
// take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, "localhost:4317" will be used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithEndpoint(endpoint string) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithEndpointURL sets the target endpoint URL the Exporter will connect to. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | ||
// environment variable is set, and this option is not passed, that variable | ||
// value will be used. If both are set, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | ||
// will take precedence. | ||
// | ||
// If both this option and WithEndpoint are used, the last used option will | ||
// take precedence. | ||
// | ||
// If an invalid URL is provided, the default value will be kept. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, "localhost:4317" will be used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithEndpointURL(u string) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithReconnectionPeriod set the minimum amount of time between connection | ||
// attempts to the target endpoint. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithReconnectionPeriod(rp time.Duration) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithCompressor sets the compressor the gRPC client uses. | ||
// Supported compressor values: "gzip". | ||
// | ||
// If the OTEL_EXPORTER_OTLP_COMPRESSION or | ||
// OTEL_EXPORTER_OTLP_LOGS_COMPRESSION environment variable is set, and | ||
// this option is not passed, that variable value will be used. That value can | ||
// be either "none" or "gzip". If both are set, | ||
// OTEL_EXPORTER_OTLP_LOGS_COMPRESSION will take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, no compressor will be used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithCompressor(compressor string) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithHeaders will send the provided headers with each gRPC requests. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_HEADERS or OTEL_EXPORTER_OTLP_LOGS_HEADERS | ||
// environment variable is set, and this option is not passed, that variable | ||
// value will be used. The value will be parsed as a list of key value pairs. | ||
// These pairs are expected to be in the W3C Correlation-Context format | ||
// without additional semi-colon delimited metadata (i.e. "k1=v1,k2=v2"). If | ||
// both are set, OTEL_EXPORTER_OTLP_LOGS_HEADERS will take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, no user headers will be set. | ||
func WithHeaders(headers map[string]string) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithTLSCredentials sets the gRPC connection to use creds. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_CERTIFICATE or | ||
// OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE environment variable is set, and | ||
// this option is not passed, that variable value will be used. The value will | ||
// be parsed the filepath of the TLS certificate chain to use. If both are | ||
// set, OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE will take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, no TLS credentials will be used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithTLSCredentials(_ credentials.TransportCredentials) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithServiceConfig defines the default gRPC service config used. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithServiceConfig(serviceConfig string) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithDialOption sets explicit grpc.DialOptions to use when establishing a | ||
// gRPC connection. The options here are appended to the internal grpc.DialOptions | ||
// used so they will take precedence over any other internal grpc.DialOptions | ||
// they might conflict with. | ||
// The [grpc.WithBlock], [grpc.WithTimeout], and [grpc.WithReturnConnectionError] | ||
// grpc.DialOptions are ignored. | ||
// | ||
// This option has no effect if WithGRPCConn is used. | ||
func WithDialOption(_ ...grpc.DialOption) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithGRPCConn sets conn as the gRPC ClientConn used for all communication. | ||
// | ||
// This option takes precedence over any other option that relates to | ||
// establishing or persisting a gRPC connection to a target endpoint. Any | ||
// other option of those types passed will be ignored. | ||
// | ||
// It is the callers responsibility to close the passed conn. The Exporter | ||
// Shutdown method will not close this connection. | ||
func WithGRPCConn(_ *grpc.ClientConn) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithTimeout sets the max amount of time an Exporter will attempt an export. | ||
// | ||
// This takes precedence over any retry settings defined by WithRetry. Once | ||
// this time limit has been reached the export is abandoned and the log | ||
// data is dropped. | ||
// | ||
// If the OTEL_EXPORTER_OTLP_TIMEOUT or OTEL_EXPORTER_OTLP_LOGS_TIMEOUT | ||
// environment variable is set, and this option is not passed, that variable | ||
// value will be used. The value will be parsed as an integer representing the | ||
// timeout in milliseconds. If both are set, | ||
// OTEL_EXPORTER_OTLP_LOGS_TIMEOUT will take precedence. | ||
// | ||
// By default, if an environment variable is not set, and this option is not | ||
// passed, a timeout of 10 seconds will be used. | ||
func WithTimeout(duration time.Duration) Option { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// WithRetry sets the retry policy for transient retryable errors that are | ||
// returned by the target endpoint. | ||
// | ||
// If the target endpoint responds with not only a retryable error, but | ||
// explicitly returns a backoff time in the response, that time will take | ||
// precedence over these settings. | ||
// | ||
// These settings do not define any network retry strategy. That is entirely | ||
// handled by the gRPC ClientConn. | ||
// | ||
// If unset, the default retry policy will be used. It will retry the export | ||
// 5 seconds after receiving a retryable error and increase exponentially | ||
// after each error for no more than a total time of 1 minute. | ||
func WithRetry(settings RetryConfig) Option { | ||
// TODO: implement. | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package otlploggrpc provides an OTLP log exporter. The exporter uses gRPC to | ||
// transport OTLP protobuf payloads. | ||
package otlploggrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package otlploggrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel/sdk/log" | ||
) | ||
|
||
// Exporter is a OpenTelemetry log Exporter. It transports log data encoded as | ||
// OTLP protobufs using gRPC. | ||
type Exporter struct { | ||
// TODO: implement. | ||
} | ||
|
||
// Compile-time check Exporter implements [log.Exporter]. | ||
var _ log.Exporter = (*Exporter)(nil) | ||
|
||
// New returns a new [Exporter]. | ||
func New(_ context.Context, options ...Option) (*Exporter, error) { | ||
cfg := newConfig(options) | ||
c, err := newClient(cfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return newExporter(c, cfg) | ||
} | ||
|
||
func newExporter(*client, config) (*Exporter, error) { | ||
// TODO: implement | ||
return &Exporter{}, nil | ||
} | ||
|
||
// Export transforms and transmits log records to an OTLP receiver. | ||
func (e *Exporter) Export(ctx context.Context, records []log.Record) error { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// Shutdown shuts down the Exporter. Calls to Export or ForceFlush will perform | ||
// no operation after this is called. | ||
func (e *Exporter) Shutdown(ctx context.Context) error { | ||
// TODO: implement. | ||
return nil | ||
} | ||
|
||
// ForceFlush does nothing. The Exporter holds no state. | ||
func (e *Exporter) ForceFlush(ctx context.Context) error { | ||
// TODO: implement. | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.9.0 | ||
go.opentelemetry.io/otel/sdk/log v0.2.0-alpha | ||
google.golang.org/grpc v1.63.2 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
go.opentelemetry.io/otel v1.26.0 // indirect | ||
go.opentelemetry.io/otel/log v0.2.0-alpha // indirect | ||
go.opentelemetry.io/otel/metric v1.26.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.26.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.26.0 // indirect | ||
golang.org/x/net v0.23.0 // indirect | ||
golang.org/x/sys v0.19.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace go.opentelemetry.io/otel => ../../../.. | ||
|
||
replace go.opentelemetry.io/otel/sdk/log => ../../../../sdk/log | ||
|
||
replace go.opentelemetry.io/otel/sdk => ../../../../sdk | ||
|
||
replace go.opentelemetry.io/otel/log => ../../../../log | ||
|
||
replace go.opentelemetry.io/otel/trace => ../../../../trace | ||
|
||
replace go.opentelemetry.io/otel/metric => ../../../../metric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= | ||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= | ||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | ||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | ||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= | ||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= | ||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= | ||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= | ||
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= | ||
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= | ||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= | ||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.