Skip to content

Commit

Permalink
fix up addAutoInstrumentation with typed options
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Jul 20, 2024
1 parent 198426a commit 200b023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import {
promisifyAll,
startTrace,
setSpanError,
addAutoInstrumentation,
} from './instrument';

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down Expand Up @@ -2096,6 +2097,7 @@ export {MutationGroup};
*/
import * as protos from '../protos/protos';
import IInstanceConfig = instanceAdmin.spanner.admin.instance.v1.IInstanceConfig;
export {addAutoInstrumentation};
export {v1, protos};
export default {Spanner};
export {Float32, Float, Int, Struct, Numeric, PGNumeric, SpannerDate};
14 changes: 8 additions & 6 deletions src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ Notes and requests from peer review:
please see /~https://github.com/googleapis/java-spanner?tab=readme-ov-file#opentelemetry-configuration.
*/

export function addAutoInstrumentation(opts: {
grpc?: boolean;
interface autoInstrumentOpts {
grpc: boolean;
http: boolean;
traceProvider: typeof TracerProvider;
}) {
tracerProvider: typeof TracerProvider;
}

export function addAutoInstrumentation(opts: autoInstrumentOpts) {
const instrumentations: (typeof Instrumentation)[] = [];

if (opts.grpc) {
Expand All @@ -93,9 +95,9 @@ export function addAutoInstrumentation(opts: {
return;
}

if (opts.traceProvider) {
if (opts.tracerProvider) {
instrumentations.forEach(instrumentation => {
instrumentation.setTraceProvider(opts.traceProvider);
instrumentation.setTracerProvider(opts.tracerProvider);
instrumentation.enable();
});
} else {
Expand Down

0 comments on commit 200b023

Please sign in to comment.