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
6 changes: 6 additions & 0 deletions .changesets/default-service-name-to-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
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.
6 changes: 4 additions & 2 deletions lib/appsignal/opentelemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ def shutdown

# Build the OpenTelemetry Resource that carries AppSignal config to the
# collector. Attributes whose underlying option is nil or an empty array
# are omitted so the collector applies its own defaults.
# are omitted so the collector applies its own defaults. The revision,
# service name and host name are the exception: they fall back to a
# value here, so they are always sent.
def build_resource(config)
revision = config[:revision].to_s.empty? ? "unknown" : config[:revision]
service_name = config[:service_name].to_s.empty? ? "unknown" : config[:service_name]
service_name = config[:service_name].to_s.empty? ? "app" : config[:service_name]
host_name = config[:hostname].to_s.empty? ? "unknown" : config[:hostname]

attrs = {
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/appsignal/opentelemetry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def with_leaked_ambient_context
.to eq(["IgnoredController#action"])
end

it "falls back to 'unknown' for empty revision, service_name, and hostname" do
it "falls back to defaults for empty revision, service_name, and hostname" do
# Other specs in the suite set `ENV["APP_REVISION"]` without clearing
# it (the spec_helper before-block only resets APPSIGNAL_* and
# _APPSIGNAL_* prefixed vars). Clear it locally so this test is
Expand All @@ -385,7 +385,7 @@ def with_leaked_ambient_context
attrs = resource_attrs(resource)

expect(attrs["appsignal.config.revision"]).to eq("unknown")
expect(attrs["service.name"]).to eq("unknown")
expect(attrs["service.name"]).to eq("app")
expect(attrs["host.name"]).to eq("unknown")
end

Expand Down
Loading