Skip to content
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

OTLP: Span.Status is not populated from Activity.Status #2503

Closed
zakimaksyutov opened this issue Oct 21, 2021 · 3 comments
Closed

OTLP: Span.Status is not populated from Activity.Status #2503

zakimaksyutov opened this issue Oct 21, 2021 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@zakimaksyutov
Copy link

Bug Report

List of NuGet packages and
version that you are using (e.g. OpenTelemetry 1.0.2):

<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.2.0-alpha1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0-beta1" />

Runtime version (e.g. net461, net48, netcoreapp3.1, net5.0 etc. You can
find this information from the *.csproj file):

net5.0

Symptom

Activity.SetStatus is not propagated into Span.Status.

using (var activity = MyActivitySource.StartActivity("MyActivity", ActivityKind.Producer))
{
  activity?.SetStatus(ActivityStatusCode.Error);
}

image

What is the expected behavior?

Span.Status contains information from Activity (success/failure + [optional] message)

What is the actual behavior?

Span.Status is always null

@zakimaksyutov zakimaksyutov added the bug Something isn't working label Oct 21, 2021
@zakimaksyutov zakimaksyutov changed the title Span.Status is not populated from Activity.Status OTLP: Span.Status is not populated from Activity.Status Oct 21, 2021
@alanwest
Copy link
Member

Confirmed this is an issue.

The reason is that Activity.SetStatus has been introduced into System.DiagnosticSource 6.0 and the OpenTelemetry API takes a dependency on this package.

Prior to 6.0, .NET did not support SetStatus, so the OpenTelemetry .NET project supplies an extension method. See:

/// <summary>
/// Sets the status of activity execution.
/// Activity class in .NET does not support 'Status'.
/// This extension provides a workaround to store Status as special tags with key name of otel.status_code and otel.status_description.
/// Read more about SetStatus here https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status.
/// </summary>
/// <param name="activity">Activity instance.</param>
/// <param name="status">Activity execution status.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "ActivityProcessor is hot path")]
public static void SetStatus(this Activity activity, Status status)
{

We need to support the newly introduced official SetStatus method.

In case you need an immediate workaround, you can use the extension method by declaring using OpenTelemetry.Trace.

@cijothomas
Copy link
Member

Related to this: #2064

@cijothomas cijothomas added this to the 1.2.0 milestone Nov 16, 2021
@cijothomas
Copy link
Member

Closing as duplicate, as this is tracked in #2569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants