Skip to content

Commit aacbf03

Browse files
authored
[doc] added clarification for Processors about TagObjects (#5445)
1 parent 3ff1df2 commit aacbf03

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/trace/extending-the-sdk/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ not covered by the built-in exporters:
3838
* Exporters should avoid generating telemetry and causing live-loop, this can be
3939
done via `OpenTelemetry.SuppressInstrumentationScope`.
4040
* Exporters should use `Activity.TagObjects` collection instead of
41-
`Activity.Tags` to obtain the full set of attributes (tags).
41+
`Activity.Tags` to obtain the full set of attributes (tags). `Activity.Tags` only
42+
returns tags whose value are of type `string` ([source](https://source.dot.net/#System.Diagnostics.DiagnosticSource/System/Diagnostics/Activity.cs,74de547549e574e0,references)).
43+
For improved performance, use [Activity.EnumerateTagObjects](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activity.enumeratetagobjects?view=net-8.0)
44+
if planning to enumerate over all TagObjects.
4245
* Exporters should use `ParentProvider.GetResource()` to get the `Resource`
4346
associated with the provider.
4447

@@ -256,6 +259,11 @@ Custom processors can be implemented to cover more scenarios:
256259
and `OnShutdown`.
257260
* `OnStart` and `OnEnd` should be thread safe, and should not block or take long
258261
time, since they will be called on critical code path.
262+
* Processors should use `Activity.TagObjects` collection instead of
263+
`Activity.Tags` to obtain the full set of attributes (tags). `Activity.Tags` only
264+
returns tags whose value are of type `string` ([source](https://source.dot.net/#System.Diagnostics.DiagnosticSource/System/Diagnostics/Activity.cs,74de547549e574e0,references)).
265+
For improved performance, use [Activity.EnumerateTagObjects](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activity.enumeratetagobjects?view=net-8.0)
266+
if planning to enumerate over all TagObjects.
259267

260268
```csharp
261269
class MyProcessor : BaseProcessor<Activity>

0 commit comments

Comments
 (0)