awsxray

package module
v0.115.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AWSOperationAttribute = "aws.operation"
	AWSAccountAttribute   = "aws.account_id"
	AWSRegionAttribute    = "aws.region"
	AWSRequestIDAttribute = "aws.request_id"
	// Currently different instrumentation uses different tag formats.
	// TODO(anuraaga): Find current instrumentation and consolidate.
	AWSRequestIDAttribute2 = "aws.requestId"
	AWSQueueURLAttribute   = "aws.queue_url"
	AWSQueueURLAttribute2  = "aws.queue.url"
	AWSServiceAttribute    = "aws.service"
	AWSTableNameAttribute  = "aws.table_name"
	AWSTableNameAttribute2 = "aws.table.name"

	// AWSXRayInProgressAttribute is the `in_progress` flag in an X-Ray segment
	AWSXRayInProgressAttribute = "aws.xray.inprogress"

	// AWSXRayXForwardedForAttribute is the `x_forwarded_for` flag in an X-Ray segment
	AWSXRayXForwardedForAttribute = "aws.xray.x_forwarded_for"

	// AWSXRayResourceARNAttribute is the `resource_arn` field in an X-Ray segment
	AWSXRayResourceARNAttribute = "aws.xray.resource_arn"

	// AWSXRayTracedAttribute is the `traced` field in an X-Ray subsegment
	AWSXRayTracedAttribute = "aws.xray.traced"

	// AWSXraySegmentAnnotationsAttribute is the attribute that
	// will be treated by the X-Ray exporter as the annotation keys.
	AWSXraySegmentAnnotationsAttribute = "aws.xray.annotations"

	// AWSXraySegmentMetadataAttributePrefix is the prefix of the attribute that
	// will be treated by the X-Ray exporter as metadata. The key of a metadata
	// will be AWSXraySegmentMetadataAttributePrefix + <metadata_key>.
	AWSXraySegmentMetadataAttributePrefix = "aws.xray.metadata."

	// AWSXrayRetriesAttribute is the `retries` field in an X-Ray (sub)segment.
	AWSXrayRetriesAttribute = "aws.xray.retries"

	// AWSXrayExceptionIDAttribute is the `id` field in an exception
	AWSXrayExceptionIDAttribute = "aws.xray.exception.id"
	// AWSXrayExceptionRemoteAttribute is the `remote` field in an exception
	AWSXrayExceptionRemoteAttribute = "aws.xray.exception.remote"
	// AWSXrayExceptionTruncatedAttribute is the `truncated` field in an exception
	AWSXrayExceptionTruncatedAttribute = "aws.xray.exception.truncated"
	// AWSXrayExceptionSkippedAttribute is the `skipped` field in an exception
	AWSXrayExceptionSkippedAttribute = "aws.xray.exception.skipped"
	// AWSXrayExceptionCauseAttribute is the `cause` field in an exception
	AWSXrayExceptionCauseAttribute = "aws.xray.exception.cause"
)

AWS-specific OpenTelemetry attribute names

Variables

This section is empty.

Functions

func String

func String(v string) *string

String returns a pointer to the provided string, or nil if it is an empty string.

func StringOrEmpty added in v0.48.0

func StringOrEmpty(v *string) string

StringOrEmpty returns empty string if the input is nil, otherwise returns the string itself.

Types

type AWSData

type AWSData struct {
	// Segment-only
	Beanstalk *BeanstalkMetadata `json:"elastic_beanstalk,omitempty"`
	CWLogs    []LogGroupMetadata `json:"cloudwatch_logs,omitempty"`
	ECS       *ECSMetadata       `json:"ecs,omitempty"`
	EC2       *EC2Metadata       `json:"ec2,omitempty"`
	EKS       *EKSMetadata       `json:"eks,omitempty"`
	XRay      *XRayMetaData      `json:"xray,omitempty"`

	// For both segment and subsegments
	AccountID    *string  `json:"account_id,omitempty"`
	Operation    *string  `json:"operation,omitempty"`
	RemoteRegion *string  `json:"region,omitempty"`
	RequestID    *string  `json:"request_id,omitempty"`
	QueueURL     *string  `json:"queue_url,omitempty"`
	TableName    *string  `json:"table_name,omitempty"`
	TableNames   []string `json:"table_names,omitempty"`
	Retries      *int64   `json:"retries,omitempty"`
}

AWSData represents the aws resource that this segment originates from

type BeanstalkMetadata

type BeanstalkMetadata struct {
	Environment  *string `json:"environment_name"`
	VersionLabel *string `json:"version_label"`
	DeploymentID *int64  `json:"deployment_id"`
}

BeanstalkMetadata represents the Elastic Beanstalk environment metadata field

type CauseData

type CauseData struct {
	Type CauseType `json:"-"`
	// it will contain one of ExceptionID or (WorkingDirectory, Paths, Exceptions)
	ExceptionID *string `json:"-"`

	CauseObject
}

CauseData is the container that contains the `cause` field

func (*CauseData) UnmarshalJSON

func (c *CauseData) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom unmarshaller for the cause field

type CauseObject

type CauseObject struct {
	WorkingDirectory *string     `json:"working_directory,omitempty"`
	Paths            []string    `json:"paths,omitempty"`
	Exceptions       []Exception `json:"exceptions,omitempty"`
}

type CauseType

type CauseType int
const (
	// CauseTypeExceptionID indicates that the type of the `cause`
	// field is a string
	CauseTypeExceptionID CauseType = iota + 1
	// CauseTypeObject indicates that the type of the `cause`
	// field is an object
	CauseTypeObject
)

type EC2Data

type EC2Data struct {
	InstanceID       *string `json:"instance_id"`
	AvailabilityZone *string `json:"availability_zone"`
}

EC2Data provides the shape for unmarshalling the ec2 field.

type EC2Metadata

type EC2Metadata struct {
	InstanceID       *string `json:"instance_id"`
	AvailabilityZone *string `json:"availability_zone"`
	InstanceSize     *string `json:"instance_size"`
	AmiID            *string `json:"ami_id"`
}

EC2Metadata represents the EC2 metadata field

type ECSData

type ECSData struct {
	Container *string `json:"container"`
}

ECSData provides the shape for unmarshalling the ecs field.

type ECSMetadata

type ECSMetadata struct {
	ContainerName    *string `json:"container,omitempty"`
	ContainerID      *string `json:"container_id,omitempty"`
	TaskArn          *string `json:"task_arn,omitempty"`
	TaskFamily       *string `json:"task_family,omitempty"`
	ClusterArn       *string `json:"cluster_arn,omitempty"`
	ContainerArn     *string `json:"container_arn,omitempty"`
	AvailabilityZone *string `json:"availability_zone,omitempty"`
	LaunchType       *string `json:"launch_type,omitempty"`
}

ECSMetadata represents the ECS metadata field. All must be omitempty b/c they come from two different detectors: Docker and ECS, so it's possible one is present and not the other

type EKSMetadata

type EKSMetadata struct {
	ClusterName *string `json:"cluster_name"`
	Pod         *string `json:"pod"`
	ContainerID *string `json:"container_id"`
}

EKSMetadata represents the EKS metadata field

type ElasticBeanstalkData

type ElasticBeanstalkData struct {
	EnvironmentName *string `json:"environment_name"`
	VersionLabel    *string `json:"version_label"`
	DeploymentID    *int    `json:"deployment_id"`
}

ElasticBeanstalkData provides the shape for unmarshalling the elastic_beanstalk field.

type Exception

type Exception struct {
	ID        *string      `json:"id,omitempty"`
	Message   *string      `json:"message,omitempty"`
	Type      *string      `json:"type,omitempty"`
	Remote    *bool        `json:"remote,omitempty"`
	Truncated *int64       `json:"truncated,omitempty"`
	Skipped   *int64       `json:"skipped,omitempty"`
	Cause     *string      `json:"cause,omitempty"`
	Stack     []StackFrame `json:"stack,omitempty"`
}

Exception represents an exception occurred

type HTTPData

type HTTPData struct {
	Request  *RequestData  `json:"request,omitempty"`
	Response *ResponseData `json:"response,omitempty"`
}

HTTPData provides the shape for unmarshalling request and response fields.

type LogGroupMetadata

type LogGroupMetadata struct {
	LogGroup *string `json:"log_group"`
	Arn      *string `json:"arn,omitempty"`
}

LogGroupMetadata represents a single CloudWatch Log Group

type RequestData

type RequestData struct {
	// Available in segment
	XForwardedFor *bool `json:"x_forwarded_for,omitempty"`

	// Available in both segment and subsegments
	Method    *string `json:"method,omitempty"`
	URL       *string `json:"url,omitempty"`
	UserAgent *string `json:"user_agent,omitempty"`
	ClientIP  *string `json:"client_ip,omitempty"`
}

RequestData provides the shape for unmarshalling the request field.

type ResponseData

type ResponseData struct {
	Status        *int64 `json:"status,omitempty"`
	ContentLength any    `json:"content_length,omitempty"`
}

ResponseData provides the shape for unmarshalling the response field.

type SQLData

type SQLData struct {
	ConnectionString *string `json:"connection_string,omitempty"`
	URL              *string `json:"url,omitempty"` // protocol://host[:port]/database
	SanitizedQuery   *string `json:"sanitized_query,omitempty"`
	DatabaseType     *string `json:"database_type,omitempty"`
	DatabaseVersion  *string `json:"database_version,omitempty"`
	DriverVersion    *string `json:"driver_version,omitempty"`
	User             *string `json:"user,omitempty"`
	Preparation      *string `json:"preparation,omitempty"` // "statement" / "call"
}

SQLData provides the shape for unmarshalling the sql field.

type Segment

type Segment struct {
	// Required fields for both segment and subsegments
	Name      *string  `json:"name"`
	ID        *string  `json:"id"`
	StartTime *float64 `json:"start_time"`

	// Segment-only optional fields
	Service     *ServiceData   `json:"service,omitempty"`
	Origin      *string        `json:"origin,omitempty"`
	User        *string        `json:"user,omitempty"`
	ResourceARN *string        `json:"resource_arn,omitempty"`
	Links       []SpanLinkData `json:"links,omitempty"`

	// Optional fields for both Segment and subsegments
	TraceID     *string                   `json:"trace_id,omitempty"`
	EndTime     *float64                  `json:"end_time,omitempty"`
	InProgress  *bool                     `json:"in_progress,omitempty"`
	HTTP        *HTTPData                 `json:"http,omitempty"`
	Fault       *bool                     `json:"fault,omitempty"`
	Error       *bool                     `json:"error,omitempty"`
	Throttle    *bool                     `json:"throttle,omitempty"`
	Cause       *CauseData                `json:"cause,omitempty"`
	AWS         *AWSData                  `json:"aws,omitempty"`
	Annotations map[string]any            `json:"annotations,omitempty"`
	Metadata    map[string]map[string]any `json:"metadata,omitempty"`
	Subsegments []Segment                 `json:"subsegments,omitempty"`

	// (for both embedded and independent) subsegment-only (optional) fields.
	// Please refer to https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-subsegments
	// for more information on subsegment.
	Namespace    *string  `json:"namespace,omitempty"`
	ParentID     *string  `json:"parent_id,omitempty"`
	Type         *string  `json:"type,omitempty"`
	PrecursorIDs []string `json:"precursor_ids,omitempty"`
	Traced       *bool    `json:"traced,omitempty"`
	SQL          *SQLData `json:"sql,omitempty"`
}

Segment schema is documented in xray-segmentdocument-schema-v1.0.0 listed on https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html

func (*Segment) Validate

func (s *Segment) Validate() error

Validate checks whether the segment is valid or not

type ServiceData

type ServiceData struct {
	Version         *string `json:"version,omitempty"`
	CompilerVersion *string `json:"compiler_version,omitempty"`
	Compiler        *string `json:"compiler,omitempty"`
}

ServiceData provides the shape for unmarshalling the service field.

type SpanLinkData added in v0.80.0

type SpanLinkData struct {
	TraceID    *string        `json:"trace_id"`
	SpanID     *string        `json:"id"`
	Attributes map[string]any `json:"attributes,omitempty"`
}

SpanLinkData provides the shape for unmarshalling the span links in the span link field.

type StackFrame

type StackFrame struct {
	Path  *string `json:"path,omitempty"`
	Line  *int    `json:"line,omitempty"`
	Label *string `json:"label,omitempty"`
}

StackFrame represents a frame in the stack when an exception occurred

type XRayClient added in v0.76.1

type XRayClient interface {
	// PutTraceSegments makes PutTraceSegments api call on X-Ray client.
	PutTraceSegments(input *xray.PutTraceSegmentsInput) (*xray.PutTraceSegmentsOutput, error)
	// PutTelemetryRecords makes PutTelemetryRecords api call on X-Ray client.
	PutTelemetryRecords(input *xray.PutTelemetryRecordsInput) (*xray.PutTelemetryRecordsOutput, error)
}

XRayClient represents X-Ray client.

func NewXRayClient added in v0.76.1

func NewXRayClient(logger *zap.Logger, awsConfig *aws.Config, buildInfo component.BuildInfo, s *session.Session) XRayClient

NewXRayClient creates a new instance of the XRay client with an AWS configuration and session.

type XRayMetaData

type XRayMetaData struct {
	SDK                 *string `json:"sdk,omitempty"`
	SDKVersion          *string `json:"sdk_version,omitempty"`
	AutoInstrumentation *bool   `json:"auto_instrumentation"`
}

XRayMetaData provides the shape for unmarshalling the xray field

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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