Source File
config.go
Belonging Package
go.opentelemetry.io/otel/sdk/resource
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0package resource // import "go.opentelemetry.io/otel/sdk/resource"import ()// config contains configuration for Resource creation.type config struct {// detectors that will be evaluated.detectors []Detector// SchemaURL to associate with the Resource.schemaURL string}// Option is the interface that applies a configuration option.type Option interface {// apply sets the Option value of a config.apply(config) config}// WithAttributes adds attributes to the configured Resource.func ( ...attribute.KeyValue) Option {return WithDetectors(detectAttributes{})}type detectAttributes struct {attributes []attribute.KeyValue}func ( detectAttributes) (context.Context) (*Resource, error) {return NewSchemaless(.attributes...), nil}// WithDetectors adds detectors to be evaluated for the configured resource.func ( ...Detector) Option {return detectorsOption{detectors: }}type detectorsOption struct {detectors []Detector}func ( detectorsOption) ( config) config {.detectors = append(.detectors, .detectors...)return}// WithFromEnv adds attributes from environment variables to the configured resource.func () Option {return WithDetectors(fromEnv{})}// WithHost adds attributes from the host to the configured resource.func () Option {return WithDetectors(host{})}// WithHostID adds host ID information to the configured resource.func () Option {return WithDetectors(hostIDDetector{})}// WithTelemetrySDK adds TelemetrySDK version info to the configured resource.func () Option {return WithDetectors(telemetrySDK{})}// WithSchemaURL sets the schema URL for the configured resource.func ( string) Option {return schemaURLOption()}type schemaURLOption stringfunc ( schemaURLOption) ( config) config {.schemaURL = string()return}// WithOS adds all the OS attributes to the configured Resource.// See individual WithOS* functions to configure specific attributes.func () Option {return WithDetectors(osTypeDetector{},osDescriptionDetector{},)}// WithOSType adds an attribute with the operating system type to the configured Resource.func () Option {return WithDetectors(osTypeDetector{})}// WithOSDescription adds an attribute with the operating system description to the// configured Resource. The formatted string is equivalent to the output of the// `uname -snrvm` command.func () Option {return WithDetectors(osDescriptionDetector{})}// WithProcess adds all the Process attributes to the configured Resource.//// Warning! This option will include process command line arguments. If these// contain sensitive information it will be included in the exported resource.//// This option is equivalent to calling WithProcessPID,// WithProcessExecutableName, WithProcessExecutablePath,// WithProcessCommandArgs, WithProcessOwner, WithProcessRuntimeName,// WithProcessRuntimeVersion, and WithProcessRuntimeDescription. See each// option function for information about what resource attributes each// includes.func () Option {return WithDetectors(processPIDDetector{},processExecutableNameDetector{},processExecutablePathDetector{},processCommandArgsDetector{},processOwnerDetector{},processRuntimeNameDetector{},processRuntimeVersionDetector{},processRuntimeDescriptionDetector{},)}// WithProcessPID adds an attribute with the process identifier (PID) to the// configured Resource.func () Option {return WithDetectors(processPIDDetector{})}// WithProcessExecutableName adds an attribute with the name of the process// executable to the configured Resource.func () Option {return WithDetectors(processExecutableNameDetector{})}// WithProcessExecutablePath adds an attribute with the full path to the process// executable to the configured Resource.func () Option {return WithDetectors(processExecutablePathDetector{})}// WithProcessCommandArgs adds an attribute with all the command arguments (including// the command/executable itself) as received by the process to the configured// Resource.//// Warning! This option will include process command line arguments. If these// contain sensitive information it will be included in the exported resource.func () Option {return WithDetectors(processCommandArgsDetector{})}// WithProcessOwner adds an attribute with the username of the user that owns the process// to the configured Resource.func () Option {return WithDetectors(processOwnerDetector{})}// WithProcessRuntimeName adds an attribute with the name of the runtime of this// process to the configured Resource.func () Option {return WithDetectors(processRuntimeNameDetector{})}// WithProcessRuntimeVersion adds an attribute with the version of the runtime of// this process to the configured Resource.func () Option {return WithDetectors(processRuntimeVersionDetector{})}// WithProcessRuntimeDescription adds an attribute with an additional description// about the runtime of the process to the configured Resource.func () Option {return WithDetectors(processRuntimeDescriptionDetector{})}// WithContainer adds all the Container attributes to the configured Resource.// See individual WithContainer* functions to configure specific attributes.func () Option {return WithDetectors(cgroupContainerIDDetector{},)}// WithContainerID adds an attribute with the id of the container to the configured Resource.// Note: WithContainerID will not extract the correct container ID in an ECS environment.// Please use the ECS resource detector instead (https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/aws/ecs).func () Option {return WithDetectors(cgroupContainerIDDetector{})}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |