Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions enrichments/trace/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ScopeConfig struct {
// spans which are identified as elastic transaction.
type ElasticTransactionConfig struct {
TimestampUs AttributeConfig `mapstructure:"timestamp_us"`
Sampled AttributeConfig `mapstructure:"sampled"`
ID AttributeConfig `mapstructure:"id"`
Root AttributeConfig `mapstructure:"root"`
Name AttributeConfig `mapstructure:"name"`
Expand Down Expand Up @@ -84,6 +85,7 @@ func Enabled() Config {
},
Transaction: ElasticTransactionConfig{
TimestampUs: AttributeConfig{Enabled: true},
Sampled: AttributeConfig{Enabled: true},
ID: AttributeConfig{Enabled: true},
Root: AttributeConfig{Enabled: true},
Name: AttributeConfig{Enabled: true},
Expand Down
1 change: 1 addition & 0 deletions enrichments/trace/internal/elastic/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
// span attributes
AttributeTimestampUs = "timestamp.us"
AttributeProcessorEvent = "processor.event"
AttributeTransactionSampled = "transaction.sampled"
AttributeTransactionID = "transaction.id"
AttributeTransactionRoot = "transaction.root"
AttributeTransactionName = "transaction.name"
Expand Down
3 changes: 3 additions & 0 deletions enrichments/trace/internal/elastic/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func (s *spanEnrichmentContext) enrichTransaction(
if cfg.TimestampUs.Enabled {
s.setTimestampUs(span)
}
if cfg.Sampled.Enabled {
span.Attributes().PutBool(AttributeTransactionSampled, true)
}
if cfg.ID.Enabled {
span.Attributes().PutStr(AttributeTransactionID, span.SpanID().String())
}
Expand Down
10 changes: 10 additions & 0 deletions enrichments/trace/internal/elastic/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: int64(0),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "",
AttributeTransactionName: "",
Expand Down Expand Up @@ -85,6 +86,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: int64(0),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "",
AttributeTransactionName: "",
Expand All @@ -108,6 +110,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand Down Expand Up @@ -137,6 +140,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand Down Expand Up @@ -165,6 +169,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand Down Expand Up @@ -194,6 +199,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand Down Expand Up @@ -223,6 +229,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand All @@ -247,6 +254,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand All @@ -271,6 +279,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand All @@ -295,6 +304,7 @@ func TestElasticTransactionEnrich(t *testing.T) {
config: config.Enabled().Transaction,
enrichedAttrs: map[string]any{
AttributeTimestampUs: startTs.AsTime().UnixMicro(),
AttributeTransactionSampled: true,
AttributeTransactionRoot: true,
AttributeTransactionID: "0100000000000000",
AttributeTransactionName: "testtxn",
Expand Down