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

feat: add gcp client attributes for Opentelemetry traces #2215

Merged
merged 2 commits into from
Jan 10, 2025
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
18 changes: 18 additions & 0 deletions observability-test/observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ describe('startTrace', () => {
'Missing OTEL_SCOPE_VERSION attribute'
);

assert.equal(
span.attributes['gcp.client.service'],
'spanner',
'Missing gcp.client.service attribute'
);

assert.equal(
span.attributes['gcp.client.version'],
TRACER_VERSION,
'Missing gcp.client.version attribute'
);

assert.equal(
span.attributes['gcp.client.repo'],
'googleapis/nodejs-spanner',
'Missing gcp.client.repo attribute'
);

assert.equal(
span.attributes[SEMATTRS_DB_SYSTEM],
'spanner',
Expand Down
3 changes: 3 additions & 0 deletions src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
span.setAttribute(SEMATTRS_DB_SYSTEM, 'spanner');
span.setAttribute(ATTR_OTEL_SCOPE_NAME, TRACER_NAME);
span.setAttribute(ATTR_OTEL_SCOPE_VERSION, TRACER_VERSION);
span.setAttribute('gcp.client.service', 'spanner');
span.setAttribute('gcp.client.version', TRACER_VERSION);
span.setAttribute('gcp.client.repo', 'googleapis/nodejs-spanner');

if (config.tableName) {
span.setAttribute(SEMATTRS_DB_SQL_TABLE, config.tableName);
Expand Down Expand Up @@ -256,11 +259,11 @@
return INVALID_SPAN_CONTEXT;
}

setAttribute(key: string, value: unknown): this {

Check warning on line 262 in src/instrument.ts

View workflow job for this annotation

GitHub Actions / lint

'key' is defined but never used

Check warning on line 262 in src/instrument.ts

View workflow job for this annotation

GitHub Actions / lint

'value' is defined but never used
return this;
}

setAttributes(attributes: SpanAttributes): this {

Check warning on line 266 in src/instrument.ts

View workflow job for this annotation

GitHub Actions / lint

'attributes' is defined but never used
return this;
}

Expand Down
Loading