Skip to content

Commit

Permalink
chore(resource-detector-instana): use exported strings for attributes
Browse files Browse the repository at this point in the history
Use exported strings for Semantic Resource Attributes

Signed-off-by: maryliag <marylia.gutierrez@grafana.com>
  • Loading branch information
maryliag committed Apr 3, 2024
1 parent 1c9aec1 commit cf558ae
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import {
processDetector,
envDetector,
} from "@opentelemetry/resources";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { instanaAgentDetector } from "@opentelemetry/resource-detector-instana";

const globalResource = new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "TestService",
[SEMRESATTRS_SERVICE_NAME]: "TestService",
});

const sdk = new NodeSDK({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.22.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
import { Detector, Resource, IResource } from '@opentelemetry/resources';
import { diag } from '@opentelemetry/api';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMRESATTRS_PROCESS_PID,
SEMRESATTRS_SERVICE_INSTANCE_ID,
} from '@opentelemetry/semantic-conventions';
import * as http from 'http';

class InstanaAgentDetector implements Detector {
Expand All @@ -32,8 +35,8 @@ class InstanaAgentDetector implements Detector {
const data = await this._retryHandler(host, port, 0);

return new Resource({
[SemanticResourceAttributes.PROCESS_PID]: data.pid,
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: data.agentUuid,
[SEMRESATTRS_PROCESS_PID]: data.pid,
[SEMRESATTRS_SERVICE_INSTANCE_ID]: data.agentUuid,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
processDetector,
envDetector,
} from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { instanaAgentDetector } from '../src';

Expand Down Expand Up @@ -54,7 +54,7 @@ describe('[Integration] instanaAgentDetector', () => {

const serviceName = 'TestService';
const globalResource = new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
[SEMRESATTRS_SERVICE_NAME]: serviceName,
});

const sdk = new NodeSDK({
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('[Integration] instanaAgentDetector', () => {

const serviceName = 'TestService';
const globalResource = new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
[SEMRESATTRS_SERVICE_NAME]: serviceName,
});

const sdk = new NodeSDK({
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf558ae

Please sign in to comment.