Repository navigation
Honour OTEL_SERVICE_NAME and send service_version as the Sentry release - #373
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 #320.
service_nameandservice_versionnow default toNoneinstead of"micro-service"and"1.0.0".OTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTES. With neither set, the name isunknown_service._build_resourcealready dropped empty values, so it needed no change.service_versionthat is set goes tosentry_sdk.initasrelease. An unset one adds noreleasekey, and sentry-sdk falls back toSENTRY_RELEASE, the git revision or CI variables, as before.sentry_additional_paramscan still override it.Some readers need a string: FastAPI's title and version, Litestar's OpenAPI title and version, Litestar's Prometheus
app_name, the health-check body, and Pyroscope'sapplication_name. They read two newBaseConfigproperties,service_name_or_defaultandservice_version_or_default, which fall back to the old strings. You chose that, so for these readers nothing changes from 1.x. The issue's breaking-change list assumed they would get a new fallback.Tests
Written first. These failed on main:
test_opentelemetry_service_name_falls_back_to_otel_service_name[config0-from-env]: withOTEL_SERVICE_NAMEset and a default config, the resource hadmicro-service. This wastest_opentelemetry_configured_service_name_wins_over_env. I renamed it because the default case now expects the variable's value. The configured cases are unchanged.test_opentelemetry_service_version_falls_back_to_otel_resource_attributes[None-from-env]:OTEL_RESOURCE_ATTRIBUTES=service.version=...was overridden by1.0.0.test_sentry_release_follows_service_version[service-version]and[service-version-wins-over-env]: no release was passed.test_service_name_and_version_fall_back_for_readers_that_need_a_string: the properties are new.test_from_object_skips_missing_attributeandtest_from_dict_drops_unknown_keys_silently: they assert the defaults, which are now None.test_sentry_release_follows_service_version[env-when-unset]coversSENTRY_RELEASEwith a default config. It passed on main and still does.These pin the fallback for the string readers and passed on main too:
test_built_app_title_and_version_fall_back_when_unset(FastAPI),test_litestar_openapi_and_prometheus_fall_back_to_default_service_name, andtest_pyroscope_application_name_falls_back_when_service_name_unset. The health-check body was already covered bytest_healthchecks_render_data_default.test_from_object_skips_none_attributeandtest_from_dict_explicit_none_overrides_defaultusedservice_nameto show that None is skipped or overrides a default. Once the default is None they could no longer tell the difference, so they useservice_debugnow.The full suite passes, 588 tests at 100% coverage (
just test-ci).just lint(includingty),just adr-checkandjust docs-buildpass too. No floor changes.Docs
configuration.mdhas a new "Service name and version" section covering what each backend does when the fields are unset. The Sentry section links to it. The resource paragraph that saidOTEL_SERVICE_NAMEgets overridden is replaced.Breaking changes
service_name,service.namenow comes fromOTEL_SERVICE_NAMEwhere it is set, and isunknown_serviceotherwise. Before, it wasmicro-service.service_version,service.versionis gone from the resource unlessOTEL_RESOURCE_ATTRIBUTESsets it.service_version, Sentry now gets it as the release, in place of the one sentry-sdk would pick, includingSENTRY_RELEASE.config.service_nameorconfig.service_versioncan now getNone. Useservice_name_or_defaultandservice_version_or_defaultfor the old values.