Skip to content

Commit

Permalink
ref(node-experimental): Add resource information (#9088)
Browse files Browse the repository at this point in the history
This was missing currently, so for correctness adding the resource info
here.
  • Loading branch information
mydea authored Sep 25, 2023
1 parent 5a8d4aa commit c326e15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/node-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@opentelemetry/instrumentation-mysql2": "~0.34.1",
"@opentelemetry/instrumentation-nestjs-core": "~0.33.1",
"@opentelemetry/instrumentation-pg": "~0.36.1",
"@opentelemetry/resources": "~1.17.0",
"@opentelemetry/sdk-trace-base": "~1.17.0",
"@opentelemetry/semantic-conventions": "~1.17.0",
"@prisma/instrumentation": "~5.3.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/node-experimental/src/sdk/initOtel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { diag, DiagLogLevel } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { AlwaysOnSampler, BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import { getCurrentHub } from '@sentry/core';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { getCurrentHub, SDK_VERSION } from '@sentry/core';
import { SentryPropagator, SentrySpanProcessor } from '@sentry/opentelemetry-node';
import { logger } from '@sentry/utils';

Expand Down Expand Up @@ -28,6 +30,11 @@ export function initOtel(): () => void {
// Create and configure NodeTracerProvider
const provider = new BasicTracerProvider({
sampler: new AlwaysOnSampler(),
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'node-experimental',
[SemanticResourceAttributes.SERVICE_NAMESPACE]: 'sentry',
[SemanticResourceAttributes.SERVICE_VERSION]: SDK_VERSION,
}),
});
provider.addSpanProcessor(new SentrySpanProcessor());

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3993,7 +3993,7 @@
"@opentelemetry/core" "1.15.2"
"@opentelemetry/semantic-conventions" "1.15.2"

"@opentelemetry/[email protected]":
"@opentelemetry/[email protected]", "@opentelemetry/resources@~1.17.0":
version "1.17.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-1.17.0.tgz#ee29144cfd7d194c69698c8153dbadec7fe6819f"
integrity sha512-+u0ciVnj8lhuL/qGRBPeVYvk7fL+H/vOddfvmOeJaA1KC+5/3UED1c9KoZQlRsNT5Kw1FaK8LkY2NVLYfOVZQw==
Expand Down

0 comments on commit c326e15

Please sign in to comment.