Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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.
8 changes: 8 additions & 0 deletions .changesets/report-host-name-when-set-to-none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
bump: patch
type: fix
---

Report `unknown` as the host name in collector mode when the `hostname`
configuration option is set to `None`. Apps that set it that way reported no
host name at all.
6 changes: 3 additions & 3 deletions src/appsignal/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ def _resource(config: Config) -> Resource:
"appsignal.config.name": config.options.get("name"),
"appsignal.config.environment": config.options.get("environment"),
"appsignal.config.push_api_key": config.options.get("push_api_key"),
"appsignal.config.revision": config.options.get("revision", "unknown"),
"appsignal.config.revision": config.options.get("revision") or "unknown",
"appsignal.config.language_integration": "python",
"service.name": config.options.get("service_name", "unknown"),
"host.name": config.options.get("hostname", "unknown"),
"service.name": config.options.get("service_name") or "app",
"host.name": config.options.get("hostname") or "unknown",
"appsignal.service.process_id": os.getpid(),
"appsignal.config.filter_attributes": config.options.get(
"filter_attributes"
Expand Down
13 changes: 12 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,25 @@ 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_values():
from appsignal.opentelemetry import _resource

config = Config(Options(revision=None, service_name=None, hostname=None))
resource = _resource(config)

assert resource.attributes["appsignal.config.revision"] == "unknown"
assert resource.attributes["service.name"] == "app"
assert resource.attributes["host.name"] == "unknown"


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