forked from open-telemetry/opentelemetry-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyEnrichingProcessor.cs
More file actions
28 lines (24 loc) · 844 Bytes
/
Copy pathMyEnrichingProcessor.cs
File metadata and controls
28 lines (24 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using System.Diagnostics;
using OpenTelemetry;
internal class MyEnrichingProcessor : BaseProcessor<Activity>
{
public override void OnEnd(Activity activity)
{
// Enrich activity with additional tags.
activity.SetTag("myCustomTag", "myCustomTagValue");
// Enriching from Baggage.
// The below snippet adds every Baggage item.
foreach (var baggage in Baggage.GetBaggage())
{
activity.SetTag(baggage.Key, baggage.Value);
}
// The below snippet adds specific Baggage item.
var deviceTypeFromBaggage = Baggage.GetBaggage("device.type");
if (deviceTypeFromBaggage != null)
{
activity.SetTag("device.type", deviceTypeFromBaggage);
}
}
}