Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changesets/default-service-name-to-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
type: change
---

Report `app` instead of `unknown` as the OpenTelemetry service name when the
`service_name` configuration option is not set and collector mode is in use.
2 changes: 1 addition & 1 deletion src/appsignal/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _resource(config: Config) -> Resource:
"appsignal.config.push_api_key": config.options.get("push_api_key"),
"appsignal.config.revision": config.options.get("revision", "unknown"),
"appsignal.config.language_integration": "python",
"service.name": config.options.get("service_name", "unknown"),
"service.name": config.options.get("service_name") or "app",
"host.name": config.options.get("hostname", "unknown"),
"appsignal.service.process_id": os.getpid(),
"appsignal.config.filter_attributes": config.options.get(
Expand Down
11 changes: 10 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,23 @@ def test_opentelemetry_resource_with_defaults():

# Test default values
assert resource.attributes["appsignal.config.revision"] == "unknown"
assert resource.attributes["service.name"] == "unknown"
assert resource.attributes["service.name"] == "app"
assert resource.attributes["appsignal.config.language_integration"] == "python"

# Test that None values are excluded
assert "appsignal.config.name" not in resource.attributes
assert "appsignal.config.push_api_key" not in resource.attributes


def test_opentelemetry_resource_with_none_service_name():
from appsignal.opentelemetry import _resource

config = Config(Options(service_name=None))
resource = _resource(config)

assert resource.attributes["service.name"] == "app"


def test_set_private_environ_valid_log_path():
cwdir = os.getcwd()
config = Config(Options(log_path=cwdir))
Expand Down
Loading