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 exporter support for limiting activity tags, events, and links #3376

Merged
merged 16 commits into from
Jul 28, 2022

Conversation

alanwest
Copy link
Member

@alanwest alanwest commented Jun 17, 2022

Fixes #3297
Related to #1453

This PR adds some support for the attribute limit configuration from the spec:

One reason these limits exist in the spec is to offer users a way to control the memory consumption of instrumentation. This PR does not help with that. In order to control memory consumption, we'd need a way for the API to honor the limits. Currently, we cannot do this. So...

The configuration is only supported by the OTLP exporter for now and therefore the limits only impact the data sent over the wire. This is beneficial for sending data to backends that have their own limitations for number and length of attributes. My plan is to follow up with this support for the other exporters.


Tangential to the primary motivation of this PR, I've introduced an SdkConfiguration class. For now, I've dropped it in the OTLP exporter project and kept it internal. Ultimately, I'd like to move this class to the SDK project, but I did not wish to hash out its design and public API as part of this PR. Also, this means the attribute limit configuration can currently only be set via environment variables. Once moved to the SDK programatic configuration would also be possible.

@codecov
Copy link

codecov bot commented Jun 23, 2022

Codecov Report

Merging #3376 (e524978) into main (25cfa17) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3376      +/-   ##
==========================================
+ Coverage   86.34%   86.40%   +0.05%     
==========================================
  Files         270      271       +1     
  Lines        9867     9910      +43     
==========================================
+ Hits         8520     8563      +43     
  Misses       1347     1347              
Impacted Files Coverage Δ
...Telemetry.Api/Internal/ActivityHelperExtensions.cs 100.00% <100.00%> (ø)
.../Configuration/EnvironmentVariableConfiguration.cs 100.00% <100.00%> (ø)
...elemetryProtocol/Configuration/SdkConfiguration.cs 100.00% <100.00%> (ø)
...metryProtocol/Implementation/ActivityExtensions.cs 91.20% <100.00%> (-3.30%) ⬇️
src/OpenTelemetry/Internal/TagTransformer.cs 100.00% <100.00%> (ø)
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 35.71% <0.00%> (-42.86%) ⬇️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 36.36% <0.00%> (-40.91%) ⬇️
...elemetry.Api/Context/RemotingRuntimeContextSlot.cs
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 97.65% <0.00%> (+0.78%) ⬆️
... and 3 more

@alanwest alanwest marked this pull request as ready for review June 23, 2022 22:22
@alanwest alanwest requested a review from a team June 23, 2022 22:22
@alanwest alanwest changed the title [WIP] Support for limiting activity tags, events, and links OTLP exporter support for limiting activity tags, events, and links Jun 23, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 2, 2022

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 2, 2022
@alanwest alanwest removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 6, 2022
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 14, 2022
Comment on lines 42 to 49
Assert.Null(config.AttributeValueLengthLimit);
Assert.Equal(128, config.AttributeCountLimit);
Assert.Null(config.SpanAttributeValueLengthLimit);
Assert.Equal(128, config.SpanAttributeCountLimit);
Assert.Equal(128, config.SpanEventCountLimit);
Assert.Equal(128, config.SpanLinkCountLimit);
Assert.Equal(128, config.EventAttributeCountLimit);
Assert.Equal(128, config.LinkAttributeCountLimit);
Copy link
Member Author

@alanwest alanwest Jul 18, 2022

Choose a reason for hiding this comment

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

This is a breaking change. I suppose the specification is a bit ambiguous here https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#attribute-limits. An SDK implementing the environment variables is a SHOULD per the spec, but it's not clear if the default values are also a SHOULD.

We have two options. Make the breaking change and consider this a bug fix - in which case I'll update the changelog to reflect this. Or maintain the prior behavior and not introduce these new defaults.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to revert this change to defaults for now so we can come back to this conversation. Setting these new defaults mean everyone takes the perf hit described here #3376 (comment)

Copy link
Contributor

@utpilla utpilla left a comment

Choose a reason for hiding this comment

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

Overall direction looks good to me.

@@ -265,7 +270,7 @@ private static class ActivityTagsEnumeratorFactory<TState>
private static readonly DictionaryEnumerator<string, object, TState>.ForEachDelegate ForEachTagValueCallbackRef = ForEachTagValueCallback;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Enumerate(Activity activity, ref TState state)
public static void Enumerate(Activity activity, ref TState state, int? maxTags)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't go with the overload approach, then maybe assign maxTags a default value of null.

@github-actions github-actions bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 28, 2022
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.

Ability to set a maximum attribute length
3 participants