package util

import (
	"context"

	"github.com/newrelic/go-agent"
)

const newRelicKey contextKey = 1

func NewRelicContext(ctx context.Context, txn newrelic.Transaction) context.Context {
	return context.WithValue(ctx, newRelicKey, txn)
}

func NewRelicFromContext(ctx context.Context) newrelic.Transaction {
	return ctx.Value(newRelicKey).(newrelic.Transaction)
}
