cloudservice

package
v0.0.0-...-75b84fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//nolint:revive // TODO(SERV) Fix revive linter
	WebsiteName = "WEBSITE_SITE_NAME"
	//nolint:revive // TODO(SERV) Fix revive linter
	RegionName = "REGION_NAME"
	//nolint:revive // TODO(SERV) Fix revive linter
	WebsiteStack = "WEBSITE_STACK"
	//nolint:revive // TODO(SERV) Fix revive linter
	AppLogsTrace = "WEBSITE_APPSERVICEAPPLOGS_TRACE_ENABLED"

	// AppServiceOrigin origin tag value
	AppServiceOrigin = "appservice"
)
View Source
const (
	//nolint:revive // TODO(SERV) Fix revive linter
	ContainerAppNameEnvVar = "CONTAINER_APP_NAME"
	//nolint:revive // TODO(SERV) Fix revive linter
	ContainerAppDNSSuffix = "CONTAINER_APP_ENV_DNS_SUFFIX"
	//nolint:revive // TODO(SERV) Fix revive linter
	ContainerAppRevision = "CONTAINER_APP_REVISION"
	//nolint:revive // TODO(SERV) Fix revive linter
	ContainerAppReplicaName = "CONTAINER_APP_REPLICA_NAME"

	//nolint:revive // TODO(SERV) Fix revive linter
	AzureSubscriptionIdEnvVar = "DD_AZURE_SUBSCRIPTION_ID"
	//nolint:revive // TODO(SERV) Fix revive linter
	AzureResourceGroupEnvVar = "DD_AZURE_RESOURCE_GROUP"

	// ContainerAppOrigin origin tag value
	ContainerAppOrigin = "containerapp"
)
View Source
const CloudRunJobsOrigin = "cloudrunjobs"

CloudRunJobsOrigin origin tag value

View Source
const CloudRunOrigin = "cloudrun"

CloudRunOrigin origin tag value

View Source
const (
	ServiceNameEnvVar = "K_SERVICE" // ServiceNameEnvVar is also used in the trace package

)

Variables

This section is empty.

Functions

func GetMetaData

func GetMetaData(config *GCPConfig, isCloudRun bool) map[string]string

GetMetaData returns the container's metadata

Types

type AppService

type AppService struct{}

AppService has helper functions for getting specific Azure Container App data

func (*AppService) GetDefaultLogsSource

func (a *AppService) GetDefaultLogsSource() string

GetDefaultLogsSource returns the default logs source if `DD_SOURCE` is not set

func (*AppService) GetOrigin

func (a *AppService) GetOrigin() string

GetOrigin returns the `origin` attribute type for the given cloud service.

func (*AppService) GetSource

func (a *AppService) GetSource() metrics.MetricSource

GetSource returns the metrics source

func (*AppService) GetStartMetricName

func (a *AppService) GetStartMetricName() string

GetStartMetricName returns the metric name for container start (coldstart) events

func (*AppService) GetTags

func (a *AppService) GetTags() map[string]string

GetTags returns a map of Azure-related tags

func (*AppService) Init

func (a *AppService) Init(_ *TracingContext) error

Init is empty for AppService

func (*AppService) ShouldForceFlushAllOnForceFlushToSerializer

func (a *AppService) ShouldForceFlushAllOnForceFlushToSerializer() bool

ShouldForceFlushAllOnForceFlushToSerializer is false usually.

func (*AppService) Shutdown

func (a *AppService) Shutdown(metricAgent serverlessMetrics.ServerlessMetricAgent, _ error)

Shutdown emits the shutdown metric for AppService

type CloudRun

type CloudRun struct {
	// contains filtered or unexported fields
}

CloudRun has helper functions for getting Google Cloud Run data

func (*CloudRun) GetDefaultLogsSource

func (c *CloudRun) GetDefaultLogsSource() string

GetDefaultLogsSource returns the default logs source if `DD_SOURCE` is not set

func (*CloudRun) GetOrigin

func (c *CloudRun) GetOrigin() string

GetOrigin returns the `origin` attribute type for the given cloud service.

func (*CloudRun) GetSource

func (c *CloudRun) GetSource() metrics.MetricSource

GetSource returns the metrics source

func (*CloudRun) GetStartMetricName

func (c *CloudRun) GetStartMetricName() string

GetStartMetricName returns the metric name for container start (coldstart) events

func (*CloudRun) GetTags

func (c *CloudRun) GetTags() map[string]string

GetTags returns a map of gcp-related tags.

func (*CloudRun) Init

func (c *CloudRun) Init(_ *TracingContext) error

Init is empty for CloudRun

func (*CloudRun) ShouldForceFlushAllOnForceFlushToSerializer

func (c *CloudRun) ShouldForceFlushAllOnForceFlushToSerializer() bool

ShouldForceFlushAllOnForceFlushToSerializer is false usually.

func (*CloudRun) Shutdown

func (c *CloudRun) Shutdown(metricAgent serverlessMetrics.ServerlessMetricAgent, _ error)

Shutdown emits the shutdown metric for CloudRun

type CloudRunJobs

type CloudRunJobs struct {
	// contains filtered or unexported fields
}

CloudRunJobs has helper functions for getting Google Cloud Run data

func (*CloudRunJobs) GetDefaultLogsSource

func (c *CloudRunJobs) GetDefaultLogsSource() string

GetDefaultLogsSource returns the default logs source if `DD_SOURCE` is not set

func (*CloudRunJobs) GetOrigin

func (c *CloudRunJobs) GetOrigin() string

GetOrigin returns the `origin` attribute type for the given cloud service.

func (*CloudRunJobs) GetSource

func (c *CloudRunJobs) GetSource() metrics.MetricSource

GetSource returns the metrics source

func (*CloudRunJobs) GetStartMetricName

func (c *CloudRunJobs) GetStartMetricName() string

GetStartMetricName returns the metric name for container start events

func (*CloudRunJobs) GetTags

func (c *CloudRunJobs) GetTags() map[string]string

GetTags returns a map of gcp-related tags for Cloud Run Jobs.

func (*CloudRunJobs) Init

func (c *CloudRunJobs) Init(ctx *TracingContext) error

Init records the start time for CloudRunJobs and initializes the job span

func (*CloudRunJobs) ShouldForceFlushAllOnForceFlushToSerializer

func (c *CloudRunJobs) ShouldForceFlushAllOnForceFlushToSerializer() bool

ShouldForceFlushAllOnForceFlushToSerializer is true for cloud run jobs.

func (*CloudRunJobs) Shutdown

func (c *CloudRunJobs) Shutdown(metricAgent serverlessMetrics.ServerlessMetricAgent, runErr error)

Shutdown submits the task duration and shutdown metrics for CloudRunJobs, and completes and submits the job span.

type CloudService

type CloudService interface {
	// GetTags returns a map of tags for a given cloud service. These tags are then attached to
	// the logs, traces, and metrics.
	GetTags() map[string]string

	// GetDefaultLogsSource returns the value that will be used for the logs source
	// if `DD_SOURCE` is not set by the user.
	GetDefaultLogsSource() string

	// GetOrigin returns the value that will be used for the `origin` attribute for
	// all logs, traces, and metrics.
	GetOrigin() string

	// GetSource returns the metrics source
	GetSource() metrics.MetricSource

	// Init bootstraps the CloudService.
	// ctx is optional and only used by CloudRunJobs for span creation
	Init(ctx *TracingContext) error

	// Shutdown cleans up the CloudService and allows emitting shutdown metrics
	Shutdown(metricAgent serverlessMetrics.ServerlessMetricAgent, runErr error)

	// GetStartMetricName returns the metric name for start events
	GetStartMetricName() string

	// ShouldForceFlushAllOnForceFlushToSerializer is used for the
	// forceFlushAll parameter on the call to forceFlushToSerializer in the
	// pkg/aggregator/demultiplexer_serverless.ServerlessDemultiplexer.ForceFlushToSerializer
	// method. This is currently necessary to support Cloud Run Jobs where the
	// shutdown flow is more abrupt than other environments. We may want to
	// unravel this thread in a cleaner way in the future.
	ShouldForceFlushAllOnForceFlushToSerializer() bool
}

CloudService implements getting tags from each Cloud Provider.

func GetCloudServiceType

func GetCloudServiceType() CloudService

GetCloudServiceType TODO: Refactor to avoid leaking individual service implementation details into the interface layer

type ContainerApp

type ContainerApp struct {
	//nolint:revive // TODO(SERV) Fix revive linter
	SubscriptionId string
	//nolint:revive // TODO(SERV) Fix revive linter
	ResourceGroup string
}

ContainerApp has helper functions for getting specific Azure Container App data

func NewContainerApp

func NewContainerApp() *ContainerApp

NewContainerApp returns a new ContainerApp instance

func (*ContainerApp) GetDefaultLogsSource

func (c *ContainerApp) GetDefaultLogsSource() string

GetDefaultLogsSource returns the default logs source if `DD_SOURCE` is not set

func (*ContainerApp) GetOrigin

func (c *ContainerApp) GetOrigin() string

GetOrigin returns the `origin` attribute type for the given cloud service.

func (*ContainerApp) GetSource

func (c *ContainerApp) GetSource() metrics.MetricSource

GetSource returns the metrics source

func (*ContainerApp) GetStartMetricName

func (c *ContainerApp) GetStartMetricName() string

GetStartMetricName returns the metric name for container start (coldstart) events

func (*ContainerApp) GetTags

func (c *ContainerApp) GetTags() map[string]string

GetTags returns a map of Azure-related tags

func (*ContainerApp) Init

func (c *ContainerApp) Init(_ *TracingContext) error

Init initializes ContainerApp specific code

func (*ContainerApp) ShouldForceFlushAllOnForceFlushToSerializer

func (c *ContainerApp) ShouldForceFlushAllOnForceFlushToSerializer() bool

ShouldForceFlushAllOnForceFlushToSerializer is false usually.

func (*ContainerApp) Shutdown

func (c *ContainerApp) Shutdown(metricAgent serverlessMetrics.ServerlessMetricAgent, _ error)

Shutdown emits the shutdown metric for ContainerApp

type GCPConfig

type GCPConfig struct {
	// contains filtered or unexported fields
}

GCPConfig holds the metadata configuration

func GetDefaultConfig

func GetDefaultConfig() *GCPConfig

GetDefaultConfig returns the medatadata's default config

type LocalService

type LocalService struct{}

func (*LocalService) GetDefaultLogsSource

func (l *LocalService) GetDefaultLogsSource() string

GetDefaultLogsSource is a default implementation that returns an empty logs source

func (*LocalService) GetOrigin

func (l *LocalService) GetOrigin() string

GetOrigin is a default implementation that returns a local empty origin

func (*LocalService) GetSource

func (l *LocalService) GetSource() metrics.MetricSource

GetSource is a default implementation that returns a metrics source

func (*LocalService) GetStartMetricName

func (l *LocalService) GetStartMetricName() string

GetStartMetricName returns the metric name for container start (coldstart) events

func (*LocalService) GetTags

func (l *LocalService) GetTags() map[string]string

GetTags is a default implementation that returns a local empty tag set

func (*LocalService) Init

func (l *LocalService) Init(_ *TracingContext) error

Init is not necessary for LocalService

func (*LocalService) ShouldForceFlushAllOnForceFlushToSerializer

func (l *LocalService) ShouldForceFlushAllOnForceFlushToSerializer() bool

ShouldForceFlushAllOnForceFlushToSerializer is false usually.

func (*LocalService) Shutdown

Shutdown emits the shutdown metric for LocalService

type TraceAgent

type TraceAgent interface {
	Process(*api.Payload)
	Flush()
	Stop()
}

TraceAgent represents a trace agent that can process trace payloads, be flushed, and stopped. This interface avoids an import cycle with pkg/serverless/trace.

type TracingContext

type TracingContext struct {
	TraceAgent TraceAgent
	SpanTags   map[string]string
}

TracingContext holds tracing dependencies used by cloud services that need them. Only CloudRunJobs currently uses this context for span creation, but it's passed to all services for interface consistency.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL