mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-15 13:53:24 +02:00
sdk/log: Scaffolding (#5068)
This commit is contained in:
parent
6bc8314a55
commit
54b6ee4174
9
.github/dependabot.yml
vendored
9
.github/dependabot.yml
vendored
@ -253,6 +253,15 @@ updates:
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: sunday
|
||||
- package-ecosystem: gomod
|
||||
directory: /sdk/log
|
||||
labels:
|
||||
- dependencies
|
||||
- go
|
||||
- Skip Changelog
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: sunday
|
||||
- package-ecosystem: gomod
|
||||
directory: /sdk/metric
|
||||
labels:
|
||||
|
@ -73,7 +73,6 @@ can be configured using following options:
|
||||
//
|
||||
// If the OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, no limit 128 will be used.
|
||||
@ -88,7 +87,6 @@ func WithAttributeCountLimit(limit int) LoggerProviderOption
|
||||
//
|
||||
// If the OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, no limit (-1) will be used.
|
||||
@ -199,7 +197,6 @@ type BatchingOption interface { /* ... */ }
|
||||
//
|
||||
// If the OTEL_BLRP_MAX_QUEUE_SIZE environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_BLRP_MAX_QUEUE_SIZE will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 2048 will be used.
|
||||
@ -210,7 +207,6 @@ func WithMaxQueueSize(max int) BatchingOption
|
||||
//
|
||||
// If the OTEL_BSP_SCHEDULE_DELAY environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_BSP_SCHEDULE_DELAY will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 1s will be used.
|
||||
@ -221,7 +217,6 @@ func WithExportInterval(d time.Duration) BatchingOption
|
||||
//
|
||||
// If the OTEL_BSP_EXPORT_TIMEOUT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_BSP_EXPORT_TIMEOUT will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 30s will be used.
|
||||
@ -232,7 +227,6 @@ func WithExportTimeout(d time.Duration) BatchingOption
|
||||
//
|
||||
// If the OTEL_BSP_MAX_EXPORT_BATCH_SIZE environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
// If both are set, OTEL_BSP_MAX_EXPORT_BATCH_SIZE will take precedence.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 512 will be used.
|
||||
|
119
sdk/log/batch.go
Normal file
119
sdk/log/batch.go
Normal file
@ -0,0 +1,119 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Compile-time check BatchingProcessor implements Processor.
|
||||
var _ Processor = (*BatchingProcessor)(nil)
|
||||
|
||||
// BatchingProcessor is an processor that asynchronously exports batches of log records.
|
||||
type BatchingProcessor struct{}
|
||||
|
||||
type batcherConfig struct{}
|
||||
|
||||
// NewBatchingProcessor decorates the provided exporter
|
||||
// so that the log records are batched before exporting.
|
||||
//
|
||||
// All of the exporter's methods are called from a single dedicated
|
||||
// background goroutine. Therefore, the expoter does not need to
|
||||
// be concurrent safe.
|
||||
func NewBatchingProcessor(exporter Exporter, opts ...BatchingOption) *BatchingProcessor {
|
||||
// TODO (#5063): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnEmit batches provided log record.
|
||||
func (b *BatchingProcessor) OnEmit(ctx context.Context, r Record) error {
|
||||
// TODO (#5063): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown flushes queued log records and shuts down the decorated expoter.
|
||||
func (b *BatchingProcessor) Shutdown(ctx context.Context) error {
|
||||
// TODO (#5063): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ForceFlush flushes queued log records and flushes the decorated expoter.
|
||||
func (b *BatchingProcessor) ForceFlush(ctx context.Context) error {
|
||||
// TODO (#5063): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// BatchingOption applies a configuration to a BatchingProcessor.
|
||||
type BatchingOption interface {
|
||||
apply(batcherConfig) batcherConfig
|
||||
}
|
||||
|
||||
type batchingOptionFunc func(batcherConfig) batcherConfig
|
||||
|
||||
func (fn batchingOptionFunc) apply(c batcherConfig) batcherConfig {
|
||||
return fn(c)
|
||||
}
|
||||
|
||||
// WithMaxQueueSize sets the maximum queue size used by the Batcher.
|
||||
// After the size is reached log records are dropped.
|
||||
//
|
||||
// If the OTEL_BLRP_MAX_QUEUE_SIZE environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 2048 will be used.
|
||||
// The default value is also used when the provided value is less than one.
|
||||
func WithMaxQueueSize(max int) BatchingOption {
|
||||
return batchingOptionFunc(func(cfg batcherConfig) batcherConfig {
|
||||
// TODO (#5063): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithExportInterval sets the maximum duration between batched exports.
|
||||
//
|
||||
// If the OTEL_BSP_SCHEDULE_DELAY environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 1s will be used.
|
||||
// The default value is also used when the provided value is less than one.
|
||||
func WithExportInterval(d time.Duration) BatchingOption {
|
||||
return batchingOptionFunc(func(cfg batcherConfig) batcherConfig {
|
||||
// TODO (#5063): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithExportTimeout sets the duration after which a batched export is canceled.
|
||||
//
|
||||
// If the OTEL_BSP_EXPORT_TIMEOUT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 30s will be used.
|
||||
// The default value is also used when the provided value is less than one.
|
||||
func WithExportTimeout(d time.Duration) BatchingOption {
|
||||
return batchingOptionFunc(func(cfg batcherConfig) batcherConfig {
|
||||
// TODO (#5063): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithExportMaxBatchSize sets the maximum batch size of every export.
|
||||
// A batch will be split into multiple exports to not exceed this size.
|
||||
//
|
||||
// If the OTEL_BSP_MAX_EXPORT_BATCH_SIZE environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 512 will be used.
|
||||
// The default value is also used when the provided value is less than one.
|
||||
func WithExportMaxBatchSize(max int) BatchingOption {
|
||||
return batchingOptionFunc(func(cfg batcherConfig) batcherConfig {
|
||||
// TODO (#5063): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
9
sdk/log/doc.go
Normal file
9
sdk/log/doc.go
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// TODO (#5065): Expand documentation stub.
|
||||
|
||||
/*
|
||||
Package log provides the OpenTelemetry Logs SDK.
|
||||
*/
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
42
sdk/log/exporter.go
Normal file
42
sdk/log/exporter.go
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Exporter handles the delivery of log records to external receivers.
|
||||
type Exporter interface {
|
||||
// Export transmits log records to a receiver.
|
||||
//
|
||||
// The deadline or cancellation of the passed context must be honored. An
|
||||
// appropriate error should be returned in these situations.
|
||||
//
|
||||
// All retry logic must be contained in this function. The SDK does not
|
||||
// implement any retry logic. All errors returned by this function are
|
||||
// considered unrecoverable and will be reported to a configured error
|
||||
// Handler.
|
||||
//
|
||||
// Implementations must not retain the records slice.
|
||||
//
|
||||
// Before modifying a Record, the implementation must use Record.Clone
|
||||
// to create a copy that shares no state with the original.
|
||||
Export(ctx context.Context, records []Record) error
|
||||
// Shutdown is called when the SDK shuts down. Any cleanup or release of
|
||||
// resources held by the exporter should be done in this call.
|
||||
//
|
||||
// The deadline or cancellation of the passed context must be honored. An
|
||||
// appropriate error should be returned in these situations.
|
||||
//
|
||||
// After Shutdown is called, calls to Export, Shutdown, or ForceFlush
|
||||
// should perform no operation and return nil error.
|
||||
Shutdown(ctx context.Context) error
|
||||
// ForceFlush exports log records to the configured Exporter that have not yet
|
||||
// been exported.
|
||||
//
|
||||
// The deadline or cancellation of the passed context must be honored. An
|
||||
// appropriate error should be returned in these situations.
|
||||
ForceFlush(ctx context.Context) error
|
||||
}
|
27
sdk/log/go.mod
Normal file
27
sdk/log/go.mod
Normal file
@ -0,0 +1,27 @@
|
||||
module go.opentelemetry.io/otel/sdk/log
|
||||
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel/log v0.0.1-alpha
|
||||
go.opentelemetry.io/otel/sdk v1.24.0
|
||||
go.opentelemetry.io/otel/trace v1.24.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/metric => ../../metric
|
||||
|
||||
replace go.opentelemetry.io/otel/trace => ../../trace
|
||||
|
||||
replace go.opentelemetry.io/otel/sdk => ../
|
||||
|
||||
replace go.opentelemetry.io/otel/log => ../../log
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
17
sdk/log/go.sum
Normal file
17
sdk/log/go.sum
Normal file
@ -0,0 +1,17 @@
|
||||
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/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
22
sdk/log/logger.go
Normal file
22
sdk/log/logger.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/log"
|
||||
"go.opentelemetry.io/otel/log/embedded"
|
||||
)
|
||||
|
||||
// Compile-time check logger implements log.Logger.
|
||||
var _ log.Logger = (*logger)(nil)
|
||||
|
||||
type logger struct {
|
||||
embedded.Logger
|
||||
}
|
||||
|
||||
func (l *logger) Emit(ctx context.Context, r log.Record) {
|
||||
// TODO (#5061): Implement.
|
||||
}
|
44
sdk/log/processor.go
Normal file
44
sdk/log/processor.go
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Processor handles the processing of log records.
|
||||
//
|
||||
// Any of the Processor's methods may be called concurrently with itself
|
||||
// or with other methods. It is the responsibility of the Processor to manage
|
||||
// this concurrency.
|
||||
type Processor interface {
|
||||
// OnEmit is called when a Record is emitted.
|
||||
//
|
||||
// Implementation should not interrupt the record processing
|
||||
// if the context is canceled.
|
||||
//
|
||||
// All retry logic must be contained in this function. The SDK does not
|
||||
// implement any retry logic. All errors returned by this function are
|
||||
// considered unrecoverable and will be reported to a configured error
|
||||
// Handler.
|
||||
//
|
||||
// Before modifying a Record, the implementation must use Record.Clone
|
||||
// to create a copy that shares no state with the original.
|
||||
OnEmit(ctx context.Context, record Record) error
|
||||
// Shutdown is called when the SDK shuts down. Any cleanup or release of
|
||||
// resources held by the exporter should be done in this call.
|
||||
//
|
||||
// The deadline or cancellation of the passed context must be honored. An
|
||||
// appropriate error should be returned in these situations.
|
||||
//
|
||||
// After Shutdown is called, calls to Export, Shutdown, or ForceFlush
|
||||
// should perform no operation and return nil error.
|
||||
Shutdown(ctx context.Context) error
|
||||
// ForceFlush exports log records to the configured Exporter that have not yet
|
||||
// been exported.
|
||||
//
|
||||
// The deadline or cancellation of the passed context must be honored. An
|
||||
// appropriate error should be returned in these situations.
|
||||
ForceFlush(ctx context.Context) error
|
||||
}
|
137
sdk/log/provider.go
Normal file
137
sdk/log/provider.go
Normal file
@ -0,0 +1,137 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/log"
|
||||
"go.opentelemetry.io/otel/log/embedded"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
)
|
||||
|
||||
// Compile-time check LoggerProvider implements log.LoggerProvider.
|
||||
var _ log.LoggerProvider = (*LoggerProvider)(nil)
|
||||
|
||||
// LoggerProvider handles the creation and coordination of Loggers. All Loggers
|
||||
// created by a LoggerProvider will be associated with the same Resource.
|
||||
type LoggerProvider struct {
|
||||
embedded.LoggerProvider
|
||||
}
|
||||
|
||||
type providerConfig struct{}
|
||||
|
||||
// NewLoggerProvider returns a new and configured LoggerProvider.
|
||||
//
|
||||
// By default, the returned LoggerProvider is configured with the default
|
||||
// Resource and no Processors. Processors cannot be added after a LoggerProvider is
|
||||
// created. This means the returned LoggerProvider, one created with no
|
||||
// Processors, will perform no operations.
|
||||
func NewLoggerProvider(opts ...LoggerProviderOption) *LoggerProvider {
|
||||
// TODO (#5060): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Logger returns a new [log.Logger] with the provided name and configuration.
|
||||
//
|
||||
// This method can be called concurrently.
|
||||
func (p *LoggerProvider) Logger(name string, opts ...log.LoggerOption) log.Logger {
|
||||
// TODO (#5060): Implement.
|
||||
return &logger{}
|
||||
}
|
||||
|
||||
// Shutdown flushes queued log records and shuts down the decorated expoter.
|
||||
//
|
||||
// This method can be called concurrently.
|
||||
func (p *LoggerProvider) Shutdown(ctx context.Context) error {
|
||||
// TODO (#5060): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ForceFlush flushes all exporters.
|
||||
//
|
||||
// This method can be called concurrently.
|
||||
func (p *LoggerProvider) ForceFlush(ctx context.Context) error {
|
||||
// TODO (#5060): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoggerProviderOption applies a configuration option value to a LoggerProvider.
|
||||
type LoggerProviderOption interface {
|
||||
apply(providerConfig) providerConfig
|
||||
}
|
||||
|
||||
type loggerProviderOptionFunc func(providerConfig) providerConfig
|
||||
|
||||
func (fn loggerProviderOptionFunc) apply(c providerConfig) providerConfig {
|
||||
return fn(c)
|
||||
}
|
||||
|
||||
// WithResource associates a Resource with a LoggerProvider. This Resource
|
||||
// represents the entity producing telemetry and is associated with all Loggers
|
||||
// the LoggerProvider will create.
|
||||
//
|
||||
// By default, if this Option is not used, the default Resource from the
|
||||
// go.opentelemetry.io/otel/sdk/resource package will be used.
|
||||
func WithResource(res *resource.Resource) LoggerProviderOption {
|
||||
return loggerProviderOptionFunc(func(cfg providerConfig) providerConfig {
|
||||
// TODO (#5060): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithProcessor associates Processor with a LoggerProvider.
|
||||
//
|
||||
// By default, if this option is not used, the LoggerProvider will perform no
|
||||
// operations; no data will be exported without a processor.
|
||||
//
|
||||
// Each WithProcessor creates a separate pipeline. Use custom decorators
|
||||
// for advanced scenarios such as enriching with attributes.
|
||||
//
|
||||
// For production, use [NewBatchingProcessor] to batch log records before they are exported.
|
||||
// For testing and debugging, use [NewSimpleProcessor] to synchronously export log records.
|
||||
func WithProcessor(processor Processor) LoggerProviderOption {
|
||||
return loggerProviderOptionFunc(func(cfg providerConfig) providerConfig {
|
||||
// TODO (#5060): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithAttributeCountLimit sets the maximum allowed log record attribute count.
|
||||
// Any attribute added to a log record once this limit is reached will be dropped.
|
||||
//
|
||||
// Setting this to zero means no attributes will be recorded.
|
||||
//
|
||||
// Setting this to a negative value means no limit is applied.
|
||||
//
|
||||
// If the OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, 128 will be used.
|
||||
func WithAttributeCountLimit(limit int) LoggerProviderOption {
|
||||
return loggerProviderOptionFunc(func(cfg providerConfig) providerConfig {
|
||||
// TODO (#5060): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// AttributeValueLengthLimit sets the maximum allowed attribute value length.
|
||||
//
|
||||
// This limit only applies to string and string slice attribute values.
|
||||
// Any string longer than this value will be truncated to this length.
|
||||
//
|
||||
// Setting this to a negative value means no limit is applied.
|
||||
//
|
||||
// If the OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT environment variable is set,
|
||||
// and this option is not passed, that variable value will be used.
|
||||
//
|
||||
// By default, if an environment variable is not set, and this option is not
|
||||
// passed, no limit (-1) will be used.
|
||||
func WithAttributeValueLengthLimit(limit int) LoggerProviderOption {
|
||||
return loggerProviderOptionFunc(func(cfg providerConfig) providerConfig {
|
||||
// TODO (#5060): Implement.
|
||||
return cfg
|
||||
})
|
||||
}
|
168
sdk/log/record.go
Normal file
168
sdk/log/record.go
Normal file
@ -0,0 +1,168 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/log"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Record is a log record emitted by the Logger.
|
||||
type Record struct{}
|
||||
|
||||
// Timestamp returns the time when the log record occurred.
|
||||
func (r *Record) Timestamp() time.Time {
|
||||
// TODO (#5064): Implement.
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
// SetTimestamp sets the time when the log record occurred.
|
||||
func (r *Record) SetTimestamp(t time.Time) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// ObservedTimestamp returns the time when the log record was observed.
|
||||
func (r *Record) ObservedTimestamp() time.Time {
|
||||
// TODO (#5064): Implement.
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
// SetObservedTimestamp sets the time when the log record was observed.
|
||||
func (r *Record) SetObservedTimestamp(t time.Time) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// Severity returns the severity of the log record.
|
||||
func (r *Record) Severity() log.Severity {
|
||||
// TODO (#5064): Implement.
|
||||
return log.Severity(0)
|
||||
}
|
||||
|
||||
// SetSeverity sets the severity level of the log record.
|
||||
func (r *Record) SetSeverity(level log.Severity) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// SeverityText returns severity (also known as log level) text. This is the
|
||||
// original string representation of the severity as it is known at the source.
|
||||
func (r *Record) SeverityText() string {
|
||||
// TODO (#5064): Implement.
|
||||
return ""
|
||||
}
|
||||
|
||||
// SetSeverityText sets severity (also known as log level) text. This is the
|
||||
// original string representation of the severity as it is known at the source.
|
||||
func (r *Record) SetSeverityText(text string) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// Body returns the body of the log record.
|
||||
func (r *Record) Body() log.Value {
|
||||
// TODO (#5064): Implement.
|
||||
return log.Value{}
|
||||
}
|
||||
|
||||
// SetBody sets the body of the log record.
|
||||
func (r *Record) SetBody(v log.Value) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// WalkAttributes walks all attributes the log record holds by calling f for
|
||||
// each on each [log.KeyValue] in the [Record]. Iteration stops if f returns false.
|
||||
func (r *Record) WalkAttributes(f func(log.KeyValue) bool) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// AddAttributes adds attributes to the log record.
|
||||
func (r *Record) AddAttributes(attrs ...log.KeyValue) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// SetAttributes sets (and overrides) attributes to the log record.
|
||||
func (r *Record) SetAttributes(attrs ...log.KeyValue) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// AttributesLen returns the number of attributes in the log record.
|
||||
func (r *Record) AttributesLen() int {
|
||||
// TODO (#5064): Implement.
|
||||
return 0
|
||||
}
|
||||
|
||||
// TraceID returns the trace ID or empty array.
|
||||
func (r *Record) TraceID() trace.TraceID {
|
||||
// TODO (#5064): Implement.
|
||||
return trace.TraceID{}
|
||||
}
|
||||
|
||||
// SetTraceID sets the trace ID.
|
||||
func (r *Record) SetTraceID(id trace.TraceID) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// SpanID returns the span ID or empty array.
|
||||
func (r *Record) SpanID() trace.SpanID {
|
||||
// TODO (#5064): Implement.
|
||||
return trace.SpanID{}
|
||||
}
|
||||
|
||||
// SetSpanID sets the span ID.
|
||||
func (r *Record) SetSpanID(id trace.SpanID) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// TraceFlags returns the trace flags.
|
||||
func (r *Record) TraceFlags() trace.TraceFlags {
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetTraceFlags sets the trace flags.
|
||||
func (r *Record) SetTraceFlags(flags trace.TraceFlags) {
|
||||
// TODO (#5064): Implement.
|
||||
}
|
||||
|
||||
// Resource returns the entity that collected the log.
|
||||
func (r *Record) Resource() resource.Resource {
|
||||
// TODO (#5064): Implement.
|
||||
return resource.Resource{}
|
||||
}
|
||||
|
||||
// InstrumentationScope returns the scope that the Logger was created with.
|
||||
func (r *Record) InstrumentationScope() instrumentation.Scope {
|
||||
// TODO (#5064): Implement.
|
||||
return instrumentation.Scope{}
|
||||
}
|
||||
|
||||
// AttributeValueLengthLimit is the maximum allowed attribute value length.
|
||||
//
|
||||
// This limit only applies to string and string slice attribute values.
|
||||
// Any string longer than this value should be truncated to this length.
|
||||
//
|
||||
// Negative value means no limit should be applied.
|
||||
func (r *Record) AttributeValueLengthLimit() int {
|
||||
// TODO (#5064): Implement.
|
||||
return 0
|
||||
}
|
||||
|
||||
// AttributeCountLimit is the maximum allowed log record attribute count. Any
|
||||
// attribute added to a log record once this limit is reached should be dropped.
|
||||
//
|
||||
// Zero means no attributes should be recorded.
|
||||
//
|
||||
// Negative value means no limit should be applied.
|
||||
func (r *Record) AttributeCountLimit() int {
|
||||
// TODO (#5064): Implement.
|
||||
return 0
|
||||
}
|
||||
|
||||
// Clone returns a copy of the record with no shared state. The original record
|
||||
// and the clone can both be modified without interfering with each other.
|
||||
func (r *Record) Clone() Record {
|
||||
// TODO (#5064): Implement.
|
||||
return *r
|
||||
}
|
48
sdk/log/simple.go
Normal file
48
sdk/log/simple.go
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/sdk/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Compile-time check SimpleProcessor implements Processor.
|
||||
var _ Processor = (*SimpleProcessor)(nil)
|
||||
|
||||
// SimpleProcessor is an processor that synchronously exports log records.
|
||||
type SimpleProcessor struct{}
|
||||
|
||||
// NewSimpleProcessor is a simple Processor adapter.
|
||||
//
|
||||
// Any of the exporter's methods may be called concurrently with itself
|
||||
// or with other methods. It is the responsibility of the exporter to manage
|
||||
// this concurrency.
|
||||
//
|
||||
// This Processor is not recommended for production use. The synchronous
|
||||
// nature of this Processor make it good for testing, debugging, or
|
||||
// showing examples of other features, but it can be slow and have a high
|
||||
// computation resource usage overhead. [NewBatchingProcessor] is recommended
|
||||
// for production use instead.
|
||||
func NewSimpleProcessor(exporter Exporter) *SimpleProcessor {
|
||||
// TODO (#5062): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnEmit batches provided log record.
|
||||
func (s *SimpleProcessor) OnEmit(ctx context.Context, r Record) error {
|
||||
// TODO (#5062): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown shuts down the expoter.
|
||||
func (s *SimpleProcessor) Shutdown(ctx context.Context) error {
|
||||
// TODO (#5062): Implement.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ForceFlush flushes the exporter.
|
||||
func (s *SimpleProcessor) ForceFlush(ctx context.Context) error {
|
||||
// TODO (#5062): Implement.
|
||||
return nil
|
||||
}
|
@ -43,3 +43,4 @@ module-sets:
|
||||
- go.opentelemetry.io/otel/schema
|
||||
excluded-modules:
|
||||
- go.opentelemetry.io/otel/internal/tools
|
||||
- go.opentelemetry.io/otel/sdk/log
|
||||
|
Loading…
x
Reference in New Issue
Block a user