Skip to content

[bug] An Activity tag with a non-string value does not get transferred to the span #2651

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

Open
provegard opened this issue Mar 7, 2025 · 3 comments
Labels
bug Something isn't working comp:exporter.stackdriver Things related to OpenTelemetry.Exporter.Stackdriver

Comments

@provegard
Copy link

Component

OpenTelemetry.Exporter.Stackdriver

Package Version

Package Name Version
OpenTelemetry.Api N/A
OpenTelemetry 1.11.1
OpenTelemetry.Exporter.Stackdriver 1.0.0-beta.6

Runtime Version

net9.0

Description

Activity tags with non-string values are not present in Cloud Monitoring trace spans.

This appears to be because ActitivyExtensions.ToSpan considers only Activity.Tags, which calls _tags.EnumerateStringValues(). I believe it should use TagObjects instead, to get all tags.

Steps to Reproduce

Add a tag with a non-string value to an activity. For example, this test fails:

    [Fact]
    public void ActivityExtensions_Export_Activity_Tag_With_Non_String_Value()
    {
        var activity = new Activity("Test");
        activity.SetStartTime(activity.StartTimeUtc.ToUniversalTime());

        activity.AddTag("key", 42L);

        var span = activity.ToSpan("project1");

        Assert.Equal(42L, span.Attributes.AttributeMap["key"].IntValue);
    }

Expected Result

Tags with non-string values are included as span attributes.

Actual Result

Tags with non-string values are not included as span attributes.

Additional Context

No response

@provegard provegard added the bug Something isn't working label Mar 7, 2025
@github-actions github-actions bot added the comp:exporter.stackdriver Things related to OpenTelemetry.Exporter.Stackdriver label Mar 7, 2025
Copy link
Contributor

github-actions bot commented Mar 7, 2025

Tagging component owner(s).

@SergeyKanzhelev

@Kielek
Copy link
Contributor

Kielek commented Mar 21, 2025

@provegard, would you like to contribute the fix? I doubt that anybody else will have time/willinges to handle it.

I will be happy to review such changes.

@provegard
Copy link
Author

Sure, no problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working comp:exporter.stackdriver Things related to OpenTelemetry.Exporter.Stackdriver
Projects
None yet
Development

No branches or pull requests

2 participants