Documentation ¶
Overview ¶
Package otelsns implements carrier for SNS.
Usage ¶
Use `SnsCarrierAttributes.Inject` to inject trace context into SNS publishing.
import ( "github.com/aws/aws-sdk-go-v2/service/sns" "github.com/aws/aws-sdk-go-v2/service/sns/types" "github.com/udhos/opentelemetry-trace-sqs/otelsns" ) // publish is an example function that uses SnsCarrierAttributes.Inject to // propagate tracing context with SNS publishing. // 'ctx' holds current tracing context. func publish(ctx context.Context, topicArn, msg string) { input := &sns.PublishInput{ TopicArn: aws.String(topicArn), Message: aws.String(msg), MessageAttributes: make(map[string]types.MessageAttributeValue), } // Inject the tracing context otelsns.NewCarrier().Inject(ctx, input.MessageAttributes) // Now invoke SNS publish for input
Index ¶
- func InjectIntoSnsMessageAttributes(ctx context.Context, input *sns.PublishInput)deprecated
- func SetTextMapPropagator(propagator propagation.TextMapPropagator)
- type SnsCarrierAttributes
- func (c *SnsCarrierAttributes) Get(key string) string
- func (c *SnsCarrierAttributes) Inject(ctx context.Context, messageAttributes map[string]types.MessageAttributeValue)
- func (c *SnsCarrierAttributes) Keys() []string
- func (c *SnsCarrierAttributes) Set(key, value string)
- func (c *SnsCarrierAttributes) WithPropagator(propagator propagation.TextMapPropagator) *SnsCarrierAttributes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectIntoSnsMessageAttributes
deprecated
func InjectIntoSnsMessageAttributes(ctx context.Context, input *sns.PublishInput)
InjectIntoSnsMessageAttributes inserts tracing from context into the SNS message attributes.
Deprecated: Use c := NewCarrier() followed by c.Inject()
func SetTextMapPropagator ¶
func SetTextMapPropagator(propagator propagation.TextMapPropagator)
SetTextMapPropagator optionally replaces the default propagator (B3 with single header). Please notice that SNS only supports up to 10 attributes, then be careful when picking another propagator that might consume multiple attributes.
Types ¶
type SnsCarrierAttributes ¶
type SnsCarrierAttributes struct {
// contains filtered or unexported fields
}
SnsCarrierAttributes is a message attribute carrier for SNS. https://pkg.go.dev/go.opentelemetry.io/otel/propagation#TextMapCarrier
func NewCarrier ¶ added in v1.0.0
func NewCarrier() *SnsCarrierAttributes
NewCarrier creates a carrier for SNS.
func NewCarrierAttributes
deprecated
func NewCarrierAttributes(input *sns.PublishInput) *SnsCarrierAttributes
NewCarrierAttributes creates a carrier attached to an SNS input.
Deprecated: Use c := NewCarrier()
func (*SnsCarrierAttributes) Get ¶
func (c *SnsCarrierAttributes) Get(key string) string
Get returns the value for the key.
func (*SnsCarrierAttributes) Inject ¶ added in v1.0.0
func (c *SnsCarrierAttributes) Inject(ctx context.Context, messageAttributes map[string]types.MessageAttributeValue)
Inject inserts tracing from context into the SNS message attributes. `ctx` holds current context with trace information. `messageAttributes` should point to outgoing SNS publish MessageAttributes which will carry the trace information. `messageAttributes` must not be nil. Use Inject right before publishing out to SNS.
func (*SnsCarrierAttributes) Keys ¶
func (c *SnsCarrierAttributes) Keys() []string
Keys lists the keys in the carrier.
func (*SnsCarrierAttributes) Set ¶
func (c *SnsCarrierAttributes) Set(key, value string)
Set stores a key-value pair.
func (*SnsCarrierAttributes) WithPropagator ¶ added in v1.0.2
func (c *SnsCarrierAttributes) WithPropagator(propagator propagation.TextMapPropagator) *SnsCarrierAttributes
WithPropagator sets propagator for carrier. If unspecified, carrier uses default propagator defined with SetTextMapPropagator.