Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing default service name #887

Merged
merged 2 commits into from
Dec 6, 2022
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
4 changes: 2 additions & 2 deletions src/SDK/Resource/Detectors/SdkProvided.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
use OpenTelemetry\SemConv\ResourceAttributes;

/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value
*/
final class SdkProvided implements ResourceDetectorInterface
{
public function getResource(): ResourceInfo
{
$attributes = [
ResourceAttributes::SERVICE_NAME => 'unknown_service',
ResourceAttributes::SERVICE_NAME => 'unknown_service:php',
];

return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/SDK/ResourceInfoFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function test_all_default_resources(): void

$this->assertEquals('opentelemetry', $resource->getAttributes()->get(ResourceAttributes::TELEMETRY_SDK_NAME));
$this->assertEquals('php', $resource->getAttributes()->get(ResourceAttributes::TELEMETRY_SDK_LANGUAGE));
$this->assertEquals('unknown_service', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
$this->assertEquals('unknown_service:php', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
}

public function test_none_default_resources(): void
Expand Down Expand Up @@ -182,6 +182,6 @@ public function test_sdk_and_sdk_provided_default_resources(): void

$this->assertEquals('opentelemetry', $resource->getAttributes()->get(ResourceAttributes::TELEMETRY_SDK_NAME));
$this->assertEquals('php', $resource->getAttributes()->get(ResourceAttributes::TELEMETRY_SDK_LANGUAGE));
$this->assertEquals('unknown_service', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
$this->assertEquals('unknown_service:php', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
}
}
6 changes: 3 additions & 3 deletions tests/Unit/SDK/Resource/Detectors/SdkProvidedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class SdkProvidedTest extends TestCase
{
public function test_sdk_provided_get_resource(): void
{
$resouceDetector = new Detectors\SdkProvided();
$resource = $resouceDetector->getResource();
$resourceDetector = new Detectors\SdkProvided();
$resource = $resourceDetector->getResource();

$this->assertSame(ResourceAttributes::SCHEMA_URL, $resource->getSchemaUrl());
$this->assertSame('unknown_service', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
$this->assertSame('unknown_service:php', $resource->getAttributes()->get(ResourceAttributes::SERVICE_NAME));
}
}
2 changes: 1 addition & 1 deletion tests/Unit/SDK/Resource/ResourceInfoFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function schemaUrlsToMergeProvider()
public function test_resource_service_name_default(): void
{
$resource = ResourceInfoFactory::defaultResource();
$this->assertEquals('unknown_service', $resource->getAttributes()->get('service.name'));
$this->assertEquals('unknown_service:php', $resource->getAttributes()->get('service.name'));
}

/**
Expand Down