Skip to content

Conversation

@mattsains
Copy link
Contributor

@mattsains mattsains commented Nov 20, 2025

This is a re-submission of #3367 , after @cijothomas recommend that it should be re-introduced.

I did change the name of the config option to WithResourceAttributes to match the Rust option in the user events log exporter

I also changed the logic when this field is not provided. The default is now to include no resource attributes except for mapped fields (eg., service.name -> Part A cloud extension)

Changes

Allows users of the Geneva exporter to specify which resource attributes they want sent to Geneva. This prevents excessive trace data from being exported if there are many resource attributes which do not need to be stored.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva label Nov 20, 2025
/// WantedResourceAttributes specifies which resource attribute fields should be sent to Geneva.
///
/// Any resource attributes not in WantedResourceAttributes are ignored.
/// If WantedResourceAttributes is not provided, all resource attributes will be sent to Geneva.
Copy link
Member

Choose a reason for hiding this comment

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

all will be sent or none will be sent?

Copy link
Member

Choose a reason for hiding this comment

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

In my opinion, it should be none, so the behavior is back-compatible. To get resource attributes, users must explicitly opt-in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if a customer really wants all resource attributes, how might they accomplish that? By the way, there is a feature flag which is default off that controls this feature

Copy link
Contributor Author

@mattsains mattsains Nov 20, 2025

Choose a reason for hiding this comment

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

I've made the change you requested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you think the special resource attributes, service.name and service.instanceId, which are mapped to part A cloud extension, should also be affected by WithResourceAttributes being set to null?

Copy link
Member

Choose a reason for hiding this comment

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

By the way, there is a feature flag which is default off that controls this feature

I am not sure if we need to feature flag this at all. The WithResourceAttribute is sufficient on its own right?

if a customer really wants all resource attributes, how might they accomplish that?

By listing each attribute. Not ideal, but I also don't think this will be the common case with GenevaExporter. If there is strong need for such a capability, we can introduce a boolean 'with_all_resource`/similar that adds all attributes effectively ignore WithResourceAttributes. Alternatively, "*" can be used to mean - get all attributes - we do such thing elsewhere in GenevaExporter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove the feature flag in a future PR

Copy link
Contributor Author

@mattsains mattsains Dec 8, 2025

Choose a reason for hiding this comment

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

feature flag has been removed, and the behaviour of the attribute is that no resource attributes are sent if it is null

@codecov
Copy link

codecov bot commented Nov 20, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
528 1 527 13
View the top 1 failed test(s) by shortest run time
OpenTelemetry.Exporter.Geneva.Tests.GenevaTraceExporterTests::GenevaTraceExporter_constructor_Invalid_Input
Stack Traces | 0.01s run time
at OpenTelemetry.Exporter.Geneva.Tests.GenevaTraceExporterTests.GenevaTraceExporter_constructor_Invalid_Input() in .../_/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs:line 61

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@mattsains mattsains marked this pull request as ready for review November 20, 2025 18:57
@mattsains mattsains requested a review from a team as a code owner November 20, 2025 18:57
@Kielek Kielek changed the title Opt in resources [Exporter.Geneva] Opt in resources Nov 21, 2025
}
}

if (!isDedicatedField && (this.WithResourceAttributes == null || !this.WithResourceAttributes.Contains(entry.Key)))
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we short-circuit this entire method if this.WithResourceAttributes == null ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided that service.name and service.instanceId fields should still be used even if they're not explicitly mentioned in WithResourceAttributes, because they have a special mapping into part A cloud extension. So I don't believe the code should skip this section if it is one of those two resource attributes

/// Any resource attributes not in WithResourceAttributes are ignored.
/// If WithResourceAttributes is not provided, no resource attributes will be sent to Geneva.
/// </summary>
public IEnumerable<string>? WithResourceAttributes { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

nit: is this still controlled by a feature flag in connection string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please refer to this previous conversation: #3552 (comment)

/// Any resource attributes not in WithResourceAttributes are ignored.
/// If WithResourceAttributes is not provided, no resource attributes will be sent to Geneva.
/// </summary>
public IEnumerable<string>? WithResourceAttributes { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Should this be --> public IEnumerable? WithResourceAttributes { get; init; }

Also, AllowedResourceAttributes or ResourceAttributeFilter naming might fit better here. No strong preference will leave it to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure - would you like me to do the same to PrepopulatedFields?

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@rajkumar-rangaraj
Copy link
Member

Consider expanding the test coverage for these scenarios

  • Reserved field name in ResourceFieldNames throws
  • Invalid type in resource attribute
  • service.name auto-mapping with ResourceFieldNames
  • Empty ResourceFieldNames = [] vs null

@rajkumar-rangaraj rajkumar-rangaraj added the keep-open Prevents issues and pull requests being closed as stale label Dec 9, 2025
@mattsains
Copy link
Contributor Author

Consider expanding the test coverage for these scenarios

* Reserved field name in `ResourceFieldNames` throws

* Invalid type in resource attribute

* `service.name` auto-mapping with `ResourceFieldNames`

* Empty `ResourceFieldNames = []` vs null

Except for service.name mapping, which was already tested, I've added all of these tests in the new revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva keep-open Prevents issues and pull requests being closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants