Repository navigation
New - Stop requiring service name in service key - #689
Open
cleverchuk wants to merge 4 commits into
Open
cleverchuk wants to merge 4 commits into
cleverchuk wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 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
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.

TL;DR
The service key no longer needs to contain the service name:
SW_APM_SERVICE_KEYcan be the API token alone. The service name is taken from the final OTel resourceservice.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 provideSdkResourceProvider.Background
The service key had the form
<api token>:<service name>, and the service name inside it was the carrier for every collector call:/v1/settings/<name from key>;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 resourceservice.name, so the name had to be in the key.Changes
Single source of truth for the service name
service.namefrom the SDK resource viaSdkResourceProvider(through the tracer provider). The same code path works for declarative and system config.unknown_service:java.service.namewhen no OTel name is configured, so existing setups resolve to the same name.Composing the collector key
ServiceKeyUtils.withServiceName(key, name): builds<token>:<normalized name>from the token part of the configured key and the final name, falling back tounknown_service:java.-, strip characters outside[\w.:_-], truncate to 255) is extracted intotransformServiceNameand reused bytransformServiceKey. Only the key and settings URL are normalized; the resource keeps the configured name.RpcClientManager.getClient(OperationType)overload is removed.AGENT_SERVICE_KEYnow always holds exactly what the user configured.Deprecation and validation
swo_httpsampler andswo_profiler, and the diagnostic tool.<api_token>with the name coming fromservice.name.Dependency bump
otelAgentVersion2.33.1 -> 2.34.0,otelSdkVersion1.67.0 -> 1.68.0 (and the instrumentation gradle plugins). This brings inSdkResourceProvider, an internal and experimental API in SDK 1.68.Smoke tests
SW_APM_SERVICE_KEY, with the name moved toOTEL_SERVICE_NAME(or the declarativeservice.name). The per-run PetClinic name used by the k6 checks is unchanged.smoke-test-linux/smoke-test-windows. They were previouslysmoke-test-<os>:netty-pipeline-test-app, because both the workflow and the Gradle task appended a suffix.Behavioural notes
OTEL_SERVICE_NAME, the resource, orunknown_service:java.service.namerather than the name in the sampler/profilerservice_key.SdkResourceProvideris internal and experimental, so future SDK upgrades may need adjustment.Testing