Skip to content

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Jul 22, 2025

See #2014 (comment)

I'll add the other cloud providers, too, if this is a good pattern.

ComponentLoader.forClassLoader(ResourceComponentProviderTest.class.getClassLoader())
.load(ComponentProvider.class);
assertThat(providers).extracting(ComponentProvider::getName).containsExactly("aws");
assertThat(providers).extracting(ComponentProvider::getName).contains("aws");
Copy link
Member

Choose a reason for hiding this comment

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

I was curious about the need for changing containsExactly to contains so i tried to put this back to containsExactly to see what would happen, and noticed that in the test failure it lists console 3 times, plus an additional service:

Expecting actual:
  ["aws", "console", "console", "console", "service"]
to contain exactly (and in same order):
  ["aws"]
but some elements were not expected:
  ["console", "console", "console", "service"]

I changed the test code to get some insights into what was actually loaded to see. Looks like this is because declarative configuration is automatically adding additional console exporters for metrics and logs plus the service resource detector.

Expecting actual:
  [io.opentelemetry.contrib.aws.resource.internal.AwsResourceDetector,
    io.opentelemetry.exporter.logging.internal.ConsoleMetricExporterComponentProvider,
    io.opentelemetry.exporter.logging.internal.ConsoleSpanExporterComponentProvider,
    io.opentelemetry.exporter.logging.internal.ConsoleLogRecordExporterComponentProvider,
    io.opentelemetry.sdk.extension.incubator.fileconfig.ServiceResourceDetector]

This surprised me a bit because I thought if the metric and log exporters weren't explicitly defined, they wouldn't be configured. Is my understanding off here?

Copy link
Member Author

Choose a reason for hiding this comment

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

ComponentProvider is only about what providers are available to be loaded if they appear in the yaml

This test seems redundant when the e2e test is there - I'll delete it

Copy link
Member

@jaydeluca jaydeluca left a comment

Choose a reason for hiding this comment

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

I'll add the other cloud providers, too, if this is a good pattern.

This seems like a reasonable approach to me 👍

@zeitlinger zeitlinger marked this pull request as draft August 21, 2025 15:15
@zeitlinger
Copy link
Member Author

@jaydeluca added the same style of tests except for GCP and appserver, because they only work on a particular environment that can't easily be mocked

@zeitlinger zeitlinger marked this pull request as ready for review September 12, 2025 15:15
@zeitlinger zeitlinger requested a review from a team as a code owner September 12, 2025 15:15
Copy link
Contributor

@KarstenSchnitter KarstenSchnitter left a comment

Choose a reason for hiding this comment

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

Thanks for providing the change. I reviewed the cloud-foundry resource changes. Looks good to me.

@zeitlinger
Copy link
Member Author

@jaydeluca can you check again?

Copy link
Member

@jaydeluca jaydeluca left a comment

Choose a reason for hiding this comment

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

👍 since these endToEnd tests are all very similar we could probably create a general AbstractResourceProviderTest or utility class and just pass the attributes

@zeitlinger
Copy link
Member Author

👍 since these endToEnd tests are all very similar we could probably create a general AbstractResourceProviderTest or utility class and just pass the attributes

there is no "test-common" project in contrib - and I'm not sure this use case justifies it

@trask trask added this pull request to the merge queue Oct 4, 2025
Merged via the queue into open-telemetry:main with commit 855df7f Oct 4, 2025
25 checks passed
@zeitlinger zeitlinger deleted the cloud-provider-end-to-end-test branch October 6, 2025 10:57
dol pushed a commit to dol/opentelemetry-java-contrib that referenced this pull request Oct 9, 2025
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.

4 participants