Skip to content

Conversation

sergiofbsilva
Copy link
Contributor

@sergiofbsilva sergiofbsilva commented Sep 5, 2025

Standalone rack applications need to initialize middlewares explicitly:

Rack::Builder.new do
	use *OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args
	run lambda { |_arg| [200, { 'Content-Type' => 'text/plain' }, body] }
 end

However this doesn't take into account the new OTEL_SEMCONV_STABILITY_OPT_IN environment variable.

This PR ensures rack middleware_args are selected consistently based on OTEL_SEMCONV_STABILITY_OPT_IN environment variable.

Ensure rack middleware_args are selected consistently based on
`OTEL_SEMCONV_STABILITY_OPT_IN` environment variable.
Copy link

linux-foundation-easycla bot commented Sep 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@ericmustin
Copy link
Contributor

Thanks for opening this @sergiofbsilva . We chatted on this briefly in SIG, just wanted to clarify

  • To confirm, the issue here that you're using rack as a standalone app, and the env var OTEL_SEMCONV_STABILITY_OPT_IN isn't being respected because it isn't being by the evaluated by the middleware_args helper method?

cc @hannahramadan

@sergiofbsilva
Copy link
Contributor Author

Thanks for opening this @sergiofbsilva . We chatted on this briefly in SIG, just wanted to clarify

  • To confirm, the issue here that you're using rack as a standalone app, and the env var OTEL_SEMCONV_STABILITY_OPT_IN isn't being respected because it isn't being by the evaluated by the middleware_args helper method?

cc @hannahramadan

Yes, that's right. We want to use middleware_args without all the logic around OTEL_SEMCONV_STABILITY_OPT_IN being on the API client.

@hannahramadan
Copy link
Contributor

Thanks @sergiofbsilva! This looks like a good change, and allows users to continuing using middleware_args vs needing to explicitly add one of the new middleware_args_* methods. We look forward to reviewing when you're ready.

@sergiofbsilva
Copy link
Contributor Author

Hi @hannahramadan

I just signed the CLA and moved from Draft to Open, I think you can review it, thanks!

@sergiofbsilva
Copy link
Contributor Author

@hannahramadan updated the tests, CI was failing, updated branch.

Copy link
Contributor

@hannahramadan hannahramadan left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Thanks, @sergiofbsilva! This is much cleaner.

@kaylareopelle kaylareopelle changed the title refactor: unify rack middleware_args fix: unify rack middleware_args Oct 1, 2025
@kaylareopelle
Copy link
Contributor

@sergiofbsilva - I'm changing the conventional commit prefix to fix so that this triggers a new release. Thanks for your contribution!

@kaylareopelle kaylareopelle merged commit 8a96a78 into open-telemetry:main Oct 1, 2025
63 checks passed
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.

5 participants