feat: honor OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES - #28
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27.
Fixes LFE-16130
createRuntime()built itsNodeTracerProviderwithout aresource, so a bare provider fell back todefaultResource()only and read neitherOTEL_SERVICE_NAMEnorOTEL_RESOURCE_ATTRIBUTES. Anything a user set through those standard variables was silently dropped.The
package.jsonline is not optional@opentelemetry/resourceswas already in the tree, but only transitively — under pnpm it is not hoisted, sonode_modules/@opentelemetry/holds justapiandsdk-trace-node. pi installs extensions withnpm --legacy-peer-deps, which does not install peers. This is the same failure mode that made 0.1.0 unloadable on a fresh install (#17), so the dependency is declared explicitly. Note that no test covers that install path yet — tracked separately in LFE-16130.Verification
actual: 'unknown_service:node',expected: 'pi-agent'); the second pins that the default resource is unchanged when the variables are unset, so it passes either way by design.runPinow clearsOTEL_SERVICE_NAME/OTEL_RESOURCE_ATTRIBUTESalongside theLANGFUSE_*vars, so a developer's own environment cannot leak into a run. Confirmed by running the suite with both exported.Behavior worth knowing when reviewing
Resource attributes are not purely inert once they reach Langfuse:
service.versionpopulates the first-classversionfield on the trace and every observation (visible in the table above).deployment.environment/deployment.environment.nameset the Langfuse environment when no Langfuse environment is configured.LANGFUSE_TRACING_ENVIRONMENT— and theenvironmentkey inlangfuse.json— both take precedence, because@langfuse/otelstamps alangfuse.environmentspan attribute andextractEnvironmentprefers span attributes over resource attributes. Invalid values coerce todefaultserver-side rather than being rejected.envDetectordiscard the entireOTEL_RESOURCE_ATTRIBUTESvalue, reported only viadiag.debug, which nothing here enables.