-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Samplers should be allowed to modify tracestate #63652
Comments
Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity Issue Detailsopen-telemetry/opentelemetry-specification#988
|
If the new property is declared as get+init then the C# namespace System.Diagnostics
{
public readonly struct ActivityCreationOptions<T>
{
+ public string? TraceState { get; init; }
}
} listener.Sample = (ref ActivityCreationOptions<ActivityContext> activityOptions) =>
{
activityOptions = activityOptions with { TraceState = "rojo=00f067aa0ba902b7" };
return ActivitySamplingResult.AllDataAndRecorded;
}; |
There is no public ctor on this type (besides the parameterless ctor since it is a UPDATE: So I tried it out, and apparently it works! public readonly struct MyStruct
{
public static MyStruct Create(int a) => new MyStruct(a, 0);
private MyStruct(int a, int b)
{
A = a;
B = b;
}
public int A { get; }
public int B { get; init; }
}
public class Program
{
public static void Main(string[] args)
{
MyStruct s = MyStruct.Create(4);
s = s with { B = 5 };
Console.WriteLine(s.A);
Console.WriteLine(s.B);
}
} compiles into:
So it copies the struct, and sets the property. I tried it on .NET Framework as well. |
open-telemetry/opentelemetry-specification#988
open-telemetry/opentelemetry-dotnet#1708
The diagnostics APIs allow sampling when creating a new
Activity
object usingActivitySource
. The listeners of the Activity creation event using registeredActivityListener
will get called whenActivity
creation is requested. When calling back the listener we encapsulate allActivity
creation data inside theActivityCreationOptions
struct and pass it by ref to the callback.OpenTelemetry specification now permitting the sampling to modify the trace state of the
Activity
we may create. The proposal here is to allow setting the trace state when doing the sampling.Proposal
Usage:
Pros:
Cons
Alternative Proposal 1
Usage:
Pros:
Cons
Set
method on readonly type.Unsafe.AsRef
to mutate the field in the struct.Alternative Proposal 2
Usage:
Pros:
Cons
Alternative Proposal 3 (not desired)
Usage:
Pros:
Cons
The text was updated successfully, but these errors were encountered: