Skip to content

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

Open
@provegard

Description

@provegard

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomp:exporter.stackdriverThings related to OpenTelemetry.Exporter.Stackdriver

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions