Documentation ¶
Overview ¶
Package collector contains the wrapper for OpenTelemetry-GoogleCloud exporter to be used in opentelemetry-collector.
Index ¶
Constants ¶
const ( HTTPRequestAttributeKey = "gcp.http_request" LogNameAttributeKey = "gcp.log_name" SourceLocationAttributeKey = "gcp.source_location" TraceSampledAttributeKey = "gcp.trace_sampled" GCPTypeKey = "@type" GCPErrorReportingTypeValue = "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent" )
const ( SummaryCountPrefix = "_count" SummarySumSuffix = "_sum" )
Constants we use when translating summary metrics into GCP.
const (
DefaultTimeout = 12 * time.Second // Consistent with Cloud Monitoring's timeout
)
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶ added in v0.28.0
ValidateConfig returns an error if the provided configuration is invalid.
Types ¶
type AttributeMapping ¶ added in v0.28.0
type AttributeMapping struct { // Key is the OpenTelemetry attribute key Key string `mapstructure:"key"` // Replacement is the attribute sent to Google Cloud Trace Replacement string `mapstructure:"replacement"` }
AttributeMapping maps from an OpenTelemetry key to a Google Cloud Trace key.
type ClientConfig ¶
type ClientConfig struct { // GetClientOptions returns additional options to be passed // to the underlying Google Cloud API client. // Must be set programmatically (no support via declarative config). // If GetClientOptions returns any options, the exporter will not add the // default credentials, as those could conflict with options provided via // GetClientOptions. // Optional. GetClientOptions func() []option.ClientOption `mapstructure:"-"` Endpoint string `mapstructure:"endpoint"` // Compression specifies the compression format for Metrics and Logging gRPC requests. // Supported values: gzip. Compression string `mapstructure:"compression"` // Only has effect if Endpoint is not "" UseInsecure bool `mapstructure:"use_insecure"` // GRPCPoolSize sets the size of the connection pool in the GCP client GRPCPoolSize int `mapstructure:"grpc_pool_size"` }
type Config ¶
type Config struct { // ProjectID is the project telemetry is sent to if the gcp.project.id // resource attribute is not set. If unspecified, this is determined using // application default credentials. ProjectID string `mapstructure:"project"` UserAgent string `mapstructure:"user_agent"` ImpersonateConfig ImpersonateConfig `mapstructure:"impersonate"` TraceConfig TraceConfig `mapstructure:"trace"` LogConfig LogConfig `mapstructure:"log"` MetricConfig MetricConfig `mapstructure:"metric"` DestinationProjectQuota bool `mapstructure:"destination_project_quota"` }
Config defines configuration for Google Cloud exporter.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig creates the default configuration for exporter.
type ImpersonateConfig ¶ added in v0.31.0
type ImpersonateConfig struct { TargetPrincipal string `mapstructure:"target_principal"` Subject string `mapstructure:"subject"` Delegates []string `mapstructure:"delegates"` }
ImpersonateConfig defines configuration for service account impersonation.
type LogConfig ¶ added in v0.29.0
type LogConfig struct { // MapMonitoredResource is not exposed as an option in the configuration, but // can be used by other exporters to extend the functionality of this // exporter. It allows overriding the function used to map otel resource to // monitored resource. MapMonitoredResource func(pcommon.Resource) *monitoredrespb.MonitoredResource `mapstructure:"-"` // DefaultLogName sets the fallback log name to use when one isn't explicitly set // for a log entry. If unset, logs without a log name will raise an error. DefaultLogName string `mapstructure:"default_log_name"` // ResourceFilters, if provided, provides a list of resource filters. // Resource attributes matching any filter will be included in LogEntry labels. // Defaults to empty, which won't include any additional resource labels. ResourceFilters []ResourceFilter `mapstructure:"resource_filters"` ClientConfig ClientConfig `mapstructure:",squash"` // ServiceResourceLabels, if true, causes the exporter to copy OTel's // service.name, service.namespace, and service.instance.id resource attributes into the Cloud Logging LogEntry labels. // Disabling this option does not prevent resource_filters from adding those labels. Default is true. ServiceResourceLabels bool `mapstructure:"service_resource_labels"` // ErrorReportingType enables automatically parsing error logs to a json payload containing the // type value for GCP Error Reporting. See https://cloud.google.com/error-reporting/docs/formatting-error-messages#log-text. ErrorReportingType bool `mapstructure:"error_reporting_type"` }
type LogsExporter ¶ added in v0.29.0
type LogsExporter struct {
// contains filtered or unexported fields
}
func NewGoogleCloudLogsExporter ¶ added in v0.29.0
func (*LogsExporter) ConfigureExporter ¶ added in v0.35.2
func (l *LogsExporter) ConfigureExporter(config *logsutil.ExporterConfig)
ConfigureExporter is used by integration tests to set exporter settings not visible to users.
type MetricConfig ¶
type MetricConfig struct { // MapMonitoredResource is not exposed as an option in the configuration, but // can be used by other exporters to extend the functionality of this // exporter. It allows overriding the function used to map otel resource to // monitored resource. MapMonitoredResource func(pcommon.Resource) *monitoredrespb.MonitoredResource `mapstructure:"-"` // ExtraMetrics is an extension point for exporters to modify the metrics // before they are sent by the exporter. ExtraMetrics func(pmetric.Metrics) `mapstructure:"-"` // GetMetricName is not settable in config files, but can be used by other // exporters which extend the functionality of this exporter. It allows // customizing the naming of metrics. baseName already includes type // suffixes for summary metrics, but does not (yet) include the domain prefix GetMetricName func(baseName string, metric pmetric.Metric) (string, error) `mapstructure:"-"` // WALConfig holds configuration settings for the write ahead log. WALConfig *WALConfig `mapstructure:"experimental_wal_config"` Prefix string `mapstructure:"prefix"` // KnownDomains contains a list of prefixes. If a metric already has one // of these prefixes, the prefix is not added. KnownDomains []string `mapstructure:"known_domains"` // ResourceFilters, if provided, provides a list of resource filters. // Resource attributes matching any filter will be included in metric labels. // Defaults to empty, which won't include any additional resource labels. Note that the // service_resource_labels option operates independently from resource_filters. ResourceFilters []ResourceFilter `mapstructure:"resource_filters"` ClientConfig ClientConfig `mapstructure:",squash"` // CreateMetricDescriptorBufferSize is the buffer size for the channel // which asynchronously calls CreateMetricDescriptor. Default is 10. CreateMetricDescriptorBufferSize int `mapstructure:"create_metric_descriptor_buffer_size"` SkipCreateMetricDescriptor bool `mapstructure:"skip_create_descriptor"` // CreateServiceTimeSeries, if true, this will send all timeseries using `CreateServiceTimeSeries`. // Implicitly, this sets `SkipMetricDescriptor` to true. CreateServiceTimeSeries bool `mapstructure:"create_service_timeseries"` // InstrumentationLibraryLabels, if true, set the instrumentation_source // and instrumentation_version labels. Defaults to true. InstrumentationLibraryLabels bool `mapstructure:"instrumentation_library_labels"` // ServiceResourceLabels, if true, causes the exporter to copy OTel's // service.name, service.namespace, and service.instance.id resource attributes into the GCM timeseries metric labels. This // option is recommended to avoid writing duplicate timeseries against the same monitored // resource. Disabling this option does not prevent resource_filters from adding those // labels. Default is true. ServiceResourceLabels bool `mapstructure:"service_resource_labels"` // CumulativeNormalization normalizes cumulative metrics without start times or with // explicit reset points by subtracting subsequent points from the initial point. // It is enabled by default. Since it caches starting points, it may result in // increased memory usage. CumulativeNormalization bool `mapstructure:"cumulative_normalization"` // EnableSumOfSquaredDeviation enables calculation of an estimated sum of squared // deviation. It isn't correct, so we don't send it by default, and don't expose // it to users. For some uses, it is expected, however. EnableSumOfSquaredDeviation bool `mapstructure:"sum_of_squared_deviation"` }
type MetricsExporter ¶
type MetricsExporter struct {
// contains filtered or unexported fields
}
MetricsExporter is the GCM exporter that uses pdata directly.
func (*MetricsExporter) PushMetrics ¶
PushMetrics calls pushes pdata metrics to GCM, creating metric descriptors if necessary.
type ResourceFilter ¶
type TraceConfig ¶
type TraceConfig struct { // AttributeMappings determines how to map from OpenTelemetry attribute // keys to Google Cloud Trace keys. By default, it changes http and // service keys so that they appear more prominently in the UI. AttributeMappings []AttributeMapping `mapstructure:"attribute_mappings"` ClientConfig ClientConfig `mapstructure:",squash"` }
type TraceExporter ¶
type TraceExporter struct {
// contains filtered or unexported fields
}
TraceExporter is a wrapper struct of OT cloud trace exporter.
func (*TraceExporter) PushTraces ¶
PushTraces calls texporter.ExportSpan for each span in the given traces.
type WALConfig ¶ added in v0.39.1
type WALConfig struct { // Directory is the location to store WAL files. Directory string `mapstructure:"directory"` // MaxBackoff sets the length of time to exponentially re-try failed exports. MaxBackoff time.Duration `mapstructure:"max_backoff"` }
WALConfig defines settings for the write ahead log. WAL buffering writes data points in-order to disk before reading and exporting them. This allows for better retry logic when exporting fails (such as a network outage), because it preserves both the data on disk and the order of the data points.