Activity.SetBaggage(String, String) Method

Definition

Add or update the Activity baggage with the input key and value. If the input value is null - if the collection has any baggage with the same key, then this baggage will get removed from the collection. - otherwise, nothing will happen and the collection will not change. If the input value is not null - if the collection has any baggage with the same key, then the value mapped to this key will get updated with the new input value. - otherwise, the key and value will get added as a new baggage to the collection. Baggage item will be updated/removed only if it was originaly added to the current activity. Items inherited from the parents will not be changed/removed, new item would be added to current activity baggage instead.

C#
public System.Diagnostics.Activity SetBaggage(string key, string? value);

Parameters

key
String

The baggage key name

value
String

The baggage value mapped to the input key

Returns

this for convenient chaining.

Applies to

Produkt Versioner
.NET 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)