Skip to content

Commit 3987ef6

Browse files
authored
fix: service.name Resource attribute
Since the 0.20.0 release and the pull request #2227 it seems that serviceName is deprecated and we should use service.name instead. I havn't easily found this information in the changelog, it did require some digging to understand why the service name was now a very long unknown_service:/path/to/node. Documentation says use service.name Resource attribute instead. but it wasn't about replacing serviceName: 'yourServiceName' by service: { name: 'yourServiceName'}.
1 parent 6398bb8 commit 3987ef6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/grpc-js/tracer.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
77
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
88
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
99
const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
10+
const { ResourceAttributes } = require("@opentelemetry/semantic-conventions");
11+
const { Resource } = require("@opentelemetry/resources");
1012

1113
const EXPORTER = process.env.EXPORTER || '';
1214

1315
module.exports = (serviceName) => {
14-
const provider = new NodeTracerProvider();
16+
const provider = new NodeTracerProvider({
17+
resource: new Resource({
18+
[ResourceAttributes.SERVICE_NAME]: serviceName,
19+
}),
20+
});
1521

1622
let exporter;
1723
if (EXPORTER.toLowerCase().startsWith('z')) {

0 commit comments

Comments
 (0)