Skip to content

Add configurable service name with OTEL env fallback - #28

Merged
bezbac merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/service-name-env-detection
Aug 20, 2026
Merged

bezbac merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/service-name-env-detection

Conversation

@DavidTraina

@DavidTraina DavidTraina commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds an optional serviceName setting to the plugin config (config file or LANGFUSE_SERVICE_NAME) and makes the tracer provider honor the standard OpenTelemetry resource environment variables. The service.name resource attribute on exported spans is resolved in this order:

  1. serviceName from the plugin config (or LANGFUSE_SERVICE_NAME)
  2. OTEL_SERVICE_NAME / OTEL_RESOURCE_ATTRIBUTES
  3. The OpenTelemetry default (unknown_service:node), unchanged from today

Why

The plugin constructs a bare NodeTracerProvider, which does not read OTEL_SERVICE_NAME or OTEL_RESOURCE_ATTRIBUTES on its own, so every span was exported as unknown_service:node with no way to change it. service.name identifies the client emitting the telemetry, so both mechanisms are useful: the config option lets users name this plugin's traces explicitly (for example to tell OpenCode traffic apart from other clients reporting to the same Langfuse project), while the environment variables keep the standard OTel way of controlling resource attributes per deployment working as users would expect. An explicit config value wins over the environment; other resource attributes from OTEL_RESOURCE_ATTRIBUTES still apply either way.

How tested

Extended the integration suite with a test that runs the built plugin against a local OTLP collector and asserts all three tiers: no configuration (default unknown_service prefix, no extra attributes), environment variables only, and config overriding OTEL_SERVICE_NAME while OTEL_RESOURCE_ATTRIBUTES values still apply. pnpm run test:integration (14 tests) and pnpm run format:check pass.

@CLAassistant

CLAassistant commented Aug 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@DavidTraina
DavidTraina force-pushed the fix/service-name-env-detection branch from ec359a9 to ca10cf9 Compare August 18, 2026 19:19
@DavidTraina DavidTraina changed the title Honor OTEL resource environment variables Add configurable service name with OTEL env fallback Aug 18, 2026

@bezbac bezbac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have one minor nitpick, which I can also change myself. Otherwise, I’m very happy to merge this. Feel free to open the PR as you see fit.

Comment thread README.md Outdated
@DavidTraina
DavidTraina force-pushed the fix/service-name-env-detection branch from ca10cf9 to 689e543 Compare August 19, 2026 17:43
@DavidTraina
DavidTraina marked this pull request as ready for review August 19, 2026 17:44
@bezbac
bezbac merged commit 238dbf9 into langfuse:main Aug 20, 2026
3 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.

3 participants