Skip to content

New - Stop requiring service name in service key - #689

Open
cleverchuk wants to merge 4 commits into
mainfrom
cc/NH-152316
Open

cleverchuk wants to merge 4 commits into
mainfrom
cc/NH-152316

Conversation

@cleverchuk

Copy link
Copy Markdown
Contributor

TL;DR

The service key no longer needs to contain the service name: SW_APM_SERVICE_KEY can be the API token alone. The service name is taken from the final OTel resource service.name (e.g. OTEL_SERVICE_NAME). The agent attaches the normalized name to the token itself where the collector needs <token>:<service name> (HTTP settings and profiling gRPC). A name still provided in the key keeps working, but is deprecated and logs a warning. Also bumps the OTel javaagent to 2.34.0 and the SDK to 1.68.0, which provide SdkResourceProvider.

Background

The service key had the form <api token>:<service name>, and the service name inside it was the carrier for every collector call:

  • the HTTP settings request went to /v1/settings/<name from key>;
  • the profiling gRPC client sent the full key as api_key.

Under system config, the resource customizer wrote the resolved name back into the key. With a token-only key and no name override, that write was skipped, so the settings request went to /v1/settings/null. Declarative config had no way to use the configured resource service.name, so the name had to be in the key.

Changes

Single source of truth for the service name

  • After the SDK is built, the agent listener reads the final service.name from the SDK resource via SdkResourceProvider (through the tracer provider). The same code path works for declarative and system config.
  • The resolved name is logged and published to a small holder. The settings pollers are created while the SDK is still being built, so on their first poll they wait for the name (up to 1s), then fall back to unknown_service:java.
  • The resource customizer no longer rewrites the service key. Its naming logic is unchanged: the deprecated name in the key still feeds service.name when no OTel name is configured, so existing setups resolve to the same name.

Composing the collector key

  • New ServiceKeyUtils.withServiceName(key, name): builds <token>:<normalized name> from the token part of the configured key and the final name, falling back to unknown_service:java.
  • Name normalization (lowercase, whitespace to -, strip characters outside [\w.:_-], truncate to 255) is extracted into transformServiceName and reused by transformServiceKey. Only the key and settings URL are normalized; the resource keeps the configured name.
  • The HTTP settings reader (system and declarative) composes the key at poll time from the configured token and the published name.
  • The profiling gRPC client is created with an explicit composed key instead of reading the global config, and the implicit RpcClientManager.getClient(OperationType) overload is removed. AGENT_SERVICE_KEY now always holds exactly what the user configured.

Deprecation and validation

  • A warning is logged when the configured key contains a service name: in the system and Lambda config loaders, the declarative swo_http sampler and swo_profiler, and the diagnostic tool.
  • The diagnostic tool no longer rejects token-only keys.
  • The sample declarative configs document the key as <api_token> with the name coming from service.name.

Dependency bump

  • otelAgentVersion 2.33.1 -> 2.34.0, otelSdkVersion 1.67.0 -> 1.68.0 (and the instrumentation gradle plugins). This brings in SdkResourceProvider, an internal and experimental API in SDK 1.68.

Smoke tests

  • All smoke-test containers, the netty run task and the CI netty jobs use the bare token as SW_APM_SERVICE_KEY, with the name moved to OTEL_SERVICE_NAME (or the declarative service.name). The per-run PetClinic name used by the k6 checks is unchanged.
  • The netty CI service names become smoke-test-linux / smoke-test-windows. They were previously smoke-test-<os>:netty-pipeline-test-app, because both the workflow and the Gradle task appended a suffix.

Behavioural notes

  • Token-only keys: fully supported. The name comes from OTEL_SERVICE_NAME, the resource, or unknown_service:java.
  • Keys with a name: still honored through the unchanged resource naming logic, with a deprecation warning.
  • Declarative config: the collector now uses the resource service.name rather than the name in the sampler/profiler service_key.
  • First settings poll: waits for the agent listener (typically about 0.1s after startup, at most 1s) instead of reading the key immediately.
  • Internal API: SdkResourceProvider is internal and experimental, so future SDK upgrades may need adjustment.

Testing

  • Unit tests cover:
    • name normalization and key composition;
    • the resource customizer leaving the key untouched;
    • settings URLs built from the published name (including the wait and the fallback);
    • service name resolution from declarative and system-config SDKs;
    • the composed profiling key.
  • CI is green on the branch, including all smoke tests (Linux, Windows, release tests v1 and v2) running with token-only keys.

@cleverchuk
cleverchuk requested review from a team as code owners November 24, 2026 01:57
Copilot AI balanced review requested due to automatic review settings November 24, 2026 01:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Service-name normalization can leave HTTP and profiling clients using different names, and token-only diagnostic keys are sent in an unsupported format that can falsely report valid credentials as invalid.

2 open issues
What changed in this PR

This PR supports token-only SW_APM_SERVICE_KEY values by deriving collector service names from the final OpenTelemetry SDK resource. Legacy keys containing a service name remain supported but produce deprecation warnings.

Changes:

  • Resolve the SDK resource name after initialization and compose normalized keys for settings and profiling.
  • Update diagnostics, configuration examples, and smoke tests for token-only keys, with unit coverage for name resolution and fallback behavior.
  • Upgrade the OpenTelemetry agent, SDK, and instrumentation Gradle plugins.
File Description
smoke-tests/​src/​test/​java/​com/​solarwinds/​containers/​SpringBootWebMvcContainer.java Separates the token and service-name environment variables.
smoke-tests/​src/​test/​java/​com/​solarwinds/​containers/​PetClinicRestContainer.java Uses token-only keys while preserving the smoke-test name.
smoke-tests/​src/​test/​java/​com/​solarwinds/​containers/​ExtensionContainer.java Configures the service name separately from the token.
smoke-tests/​netty-test/​build.gradle.kts Passes the token unchanged and supplies a service-name default.
sdk-config.yaml Documents token-only keys in comments.
sdk-config-kitchen-sink.yaml Updates sampler and profiler key-format comments.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​ResourceCustomizerTest.java Verifies resource customization leaves the key unchanged.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​ResourceCustomizer.java Removes service-key rewriting and moves name logging elsewhere.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​LambdaConfigurationLoader.java Warns about names embedded in legacy keys.
libs/​core/​src/​main/​java/​com/​solarwinds/​joboe/​core/​util/​diagnostic/​DiagnosticTools.java Accepts token-only keys and updates usage guidance.
libs/​core/​src/​main/​java/​com/​solarwinds/​joboe/​core/​rpc/​RpcClientManager.java Removes implicit global-key client creation.
libs/​config/​src/​test/​java/​com/​solarwinds/​joboe/​config/​ServiceKeyUtilsTest.java Tests normalization, fallback, and key composition.
libs/​config/​src/​main/​java/​com/​solarwinds/​joboe/​config/​ServiceKeyUtils.java Adds shared name normalization and collector-key composition.
dependencyManagement/​build.gradle.kts Upgrades the OpenTelemetry agent and SDK versions.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsAgentListenerTest.java Tests SDK name resolution and profiling-key composition.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​SdkResourceServiceNameTest.java Tests name publication, waiting, and timeout behavior.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​ProfilingSpanProcessorComponentProviderTest.java Tests token-only profiler configuration.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​HttpSamplerComponentProviderTest.java Tests settings requests using resolved resource names.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReaderTest.java Tests token-only keys and published-name precedence.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsAgentListener.java Publishes the final resource name and composes profiling keys.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​SdkResourceServiceName.java Adds a shared holder with bounded startup waiting.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​ProfilingSpanProcessorComponentProvider.java Adds legacy-key deprecation warnings.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​HttpSamplerComponentProvider.java Defers collector-key composition until polling.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReader.java Uses published service names and default-name fallback.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​ConfigurationLoader.java Warns when configured keys contain a service name.
buildSrc/​build.gradle.kts Upgrades OpenTelemetry instrumentation Gradle plugins.
.github/​workflows/​push.yml Separates Netty CI tokens from platform-specific service names.

Review effort: Balanced

Comment on lines +75 to +77
return getApiKey(serviceKey)
+ SEPARATOR_CHARACTER
+ transformServiceName(serviceNameOrDefault(serviceName));
Comment on lines +373 to +374
ServiceKeyUtils.warnIfServiceNameInServiceKey(serviceKey);
String apiToken = ServiceKeyUtils.getApiKey(serviceKey);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants