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

Fix handling of OTLP ArrayValue attributes #3238

Merged
merged 4 commits into from
May 2, 2022

Conversation

alanwest
Copy link
Member

The proto has an ArrayValue. We were not using it. This PR fixes things for Activitys.

There's a slew of other bugs in and around handling OTLP attributes. Will continue to follow up with some more PRs.

@alanwest alanwest requested a review from a team April 28, 2022 22:55
Assert.Null(stringArray[2].Value);
Assert.Equal("test", stringArray.Value.ArrayValue.Values[0].StringValue);
Assert.Equal(string.Empty, stringArray.Value.ArrayValue.Values[1].StringValue);
Assert.Equal(OtlpCommon.AnyValue.ValueOneofCase.None, stringArray.Value.ArrayValue.Values[2].ValueCase);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be right. It seems closest to what we were doing before, but technically an array should be homogenous.

Comment on lines 465 to 466
default:
PooledList<OtlpCommon.KeyValue>.Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue { StringValue = activityTag.Value.ToString() }));
Copy link
Member Author

@alanwest alanwest Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little suspect. I think we should consider dropping things that do not fit the types we want to support.

ToString will often just serialize to a type name and worse it could even throw an exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Log and drop would be safer here.

}

PooledList<OtlpCommon.KeyValue>.Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue { ArrayValue = arrayValue }));
break;
case double[] doubleArray:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a number of types we're not consistently handling across everything. For example, we're not handling float or float[] in this code. Should we? Will continue discussion here #2010

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #3238 (20192e2) into main (b8aaf1a) will increase coverage by 0.13%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3238      +/-   ##
==========================================
+ Coverage   85.40%   85.53%   +0.13%     
==========================================
  Files         261      261              
  Lines        9385     9395      +10     
==========================================
+ Hits         8015     8036      +21     
+ Misses       1370     1359      -11     
Impacted Files Coverage Δ
...metryProtocol/Implementation/ActivityExtensions.cs 91.81% <80.00%> (+3.07%) ⬆️
src/OpenTelemetry/BatchExportProcessor.cs 84.21% <0.00%> (-3.16%) ⬇️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 77.27% <0.00%> (+18.18%) ⬆️
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 78.57% <0.00%> (+28.57%) ⬆️

@cijothomas
Copy link
Member

#3229 is this related as well?

@alanwest
Copy link
Member Author

#3229 is this related as well?

Yes, definitely. I want to address this as well. Problem is we have a number of disparate code paths that transform attributes to OTLP, and they're not equivalent. I imagine we may have similar issues in some of the other exporters as well (Jaeger/Zipkin).

The code path for resource attributes does not yet handle arrays. The same code path is used by the OTLP logs exporter. I suspect I can refactor things to be a little less disjointed, but I want to do things in a few passes.

I think I'm going to take on the work of #2010 - first in the context of OTLP trace data. That way we can come to a consensus of what types of attributes we want to support and then I can work on making sure everything works uniformly.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. User facing bug fix, so changelog.md also please!

@cijothomas cijothomas merged commit dff1996 into open-telemetry:main May 2, 2022
@alanwest alanwest deleted the alanwest/otlp-array-values branch September 30, 2022 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants