Disable OpenTelemetry SDK during installation#176
Conversation
Systems like GitHub Actions have env vars set to configure OpenTelemetry on the fly. The Spin CLI (telemetry crate) picks those up and tries to initialize the OTEL exporter, which fails. This commit disables OTEL SDK by setting OTEL_SDK_DISABLED=true Once all spin commands have been invoked the env var is unset again fixes: #175 Signed-off-by: Thorsten Hans <thans@akamai.com>
itowlson
left a comment
There was a problem hiding this comment.
This looks fine apart from one formatting nit, but I do wonder if this is patching the problem in the wrong place. If merely having the OTel SDK enabled causes Spin to have ructions, that seems like a bug in Spin, and should be fixed at source. But maybe I'm misunderstanding the issue.
|
@ThorstenHans can you elaborate on why Spin is having issues when the OTEL SDK is not disabled? |
Signed-off-by: Thorsten Hans <thans@akamai.com>
|
@itowlson @calebschoepp sure thing, let me share some more context. GitHub Action Runners have OTEL environment variables set, during installation of spin-docs/downloads/install.sh Line 153 in 2be2247 spin-docs/downloads/install.sh Line 163 in 2be2247 spin-docs/downloads/install.sh Line 169 in 2be2247 etc. The This is not unique to GitHub Actions, I recently stumbled upon a DevContainer base image that had those env vars set as well. By setting This issue won't be hit when using the setup action created by @rajatjindal ! However, I build a For reference: Spin DevContainer -> https://github.com/ThorstenHans/spin-devcontainer |
|
That's helpful @ThorstenHans. Do you have an example of the errors? I would expect that if the dev container is setting valid OTEL env vars things should just work. |
|
@ThorstenHans are you saying that GH Actions and the devcontainer are both setting e.g. And... I see your devcontainer already has To reiterate what Caleb said, it would be great if you could paste the actual error you're seeing - thanks! |
|
@calebschoepp @itowlson I looked into this again. It ONLY happens if one pre-builds a DevContainer (both on GH or locally). Using the installer script straight from within a GitHub Action works as expected, but when adding I've created a small repo that demonstrates this: https://github.com/ThorstenHans/tmp--spin-installer-script/ There are two actions in this repo:
The However, users that pre-built a devcontainer without using my Spin DevContainer Feature will run into the same error. I don't know if we consider this as an edge-case or not, but at least it verifies that |
@itowlson Yeah, my DevContainer is setting that, to prevent DevContainer pre-builds from failing. IMO, our installer script could set that so that other DevContainer authors doesn't have to |
|
Sorry I am being a dolt, @ThorstenHans, but I still don't understand why Spin would works in a devcontainer except during installation. What is special about installation time that we need to disable OTel then but not at other times? I would strongly prefer that we fix this in Spin, because users should be able to install their own plugins and templates in their devcontainers: they shouldn't be reliant on our specific install script. And because I would like us to understand what is happening rather than kludging past it with a global disable-enable. (Of course if nothing else works, or it's going to take a long time to fix it at source, then we'll do the kludge.) @calebschoepp The error from Thorsten's failing build link is: So I guess the devcontainer is... setting the exporter URI to garbage during initialisation and fixing it up later? I am not sure, and I don't understand either OTel or the devcontainer lifecycle well enough to have a sense for where this is all happening...! Should we make "bad exporter URI" less fatal? What do other applications do? |
+1 Hmmm it's not immediately obvious to me what's going wrong. @ThorstenHans could you log what the value of the relevant OTEL environment variables so we can see what they are. Likely Ivan is right that we shouldn't fail so fatally in the case that we're handed garbage in these OTEL env vars — we should probably just log a tracing WARN or ERROR and move on. Still it would be good to understand what the value we're barfing on is. |
This PR disables OTEL SDK during installation (otherwise executing
spincommands will fail on GH Actions)The PR also adds a small GitHub Action to run the installer whenever it is changed as part of a PR targeting
main