otelsns

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 6 Imported by: 3

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

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

WithPropagator sets propagator for carrier. If unspecified, carrier uses default propagator defined with SetTextMapPropagator.

Jump to

Keyboard shortcuts

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