From 858d06d87470de019349b5169e8f1ffd5cd52e60 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 26 Nov 2024 07:53:28 -0800 Subject: [PATCH] chore: replace deprecated substr() with substring() --- .../src/instrumentation.ts | 2 +- .../test/cassandra-driver.test.ts | 2 +- .../src/instrumentation.ts | 2 +- plugins/node/opentelemetry-instrumentation-knex/src/utils.ts | 2 +- .../opentelemetry-instrumentation-knex/test/index.test.ts | 2 +- .../src/OTTracePropagator.ts | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index 3a65a0bd6a..477bbb1126 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -392,5 +392,5 @@ function wrapPromise( } function truncateQuery(query: unknown, maxQueryLength: number) { - return String(query).substr(0, maxQueryLength); + return String(query).substring(0, maxQueryLength); } diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts b/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts index c663ab0abe..00171c8426 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts @@ -244,7 +244,7 @@ describe('CassandraDriverInstrumentation', () => { it('truncates long queries', async () => { const query = 'select userid, count from ot.test'; await client.execute(query); - assertSingleSpan('cassandra-driver.execute', query.substr(0, 25)); + assertSingleSpan('cassandra-driver.execute', query.substring(0, 25)); }); }); diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index 08df2aa533..72d8b8c9b7 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -251,7 +251,7 @@ export class FastifyInstrumentation extends InstrumentationBase { 0 < maxLength && maxLength < str.length ) { - return str.substr(0, maxLength) + '..'; + return str.substring(0, maxLength) + '..'; } return str; }; diff --git a/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts index e84dcbc398..aa00a3a9f2 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts @@ -150,7 +150,7 @@ describe('Knex instrumentation', () => { const [span] = memoryExporter.getFinishedSpans(); const limitedStatement = span?.attributes?.['db.statement'] as string; assert.strictEqual(limitedStatement.length, 52); - assert.ok(statement.startsWith(limitedStatement.substr(0, 50))); + assert.ok(statement.startsWith(limitedStatement.substring(0, 50))); }); it('should catch errors', async () => { diff --git a/propagators/opentelemetry-propagator-ot-trace/src/OTTracePropagator.ts b/propagators/opentelemetry-propagator-ot-trace/src/OTTracePropagator.ts index 9ca68f3d50..362c2bddba 100644 --- a/propagators/opentelemetry-propagator-ot-trace/src/OTTracePropagator.ts +++ b/propagators/opentelemetry-propagator-ot-trace/src/OTTracePropagator.ts @@ -67,7 +67,7 @@ export class OTTracePropagator implements TextMapPropagator { const spanContext = trace.getSpan(context)?.spanContext(); if (!spanContext || !isSpanContextValid(spanContext)) return; - setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId.substr(16)); + setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId.substring(16)); setter.set(carrier, OT_SPAN_ID_HEADER, spanContext.spanId); setter.set( carrier, @@ -110,7 +110,7 @@ export class OTTracePropagator implements TextMapPropagator { getter.keys(carrier).forEach(k => { if (!k.startsWith(OT_BAGGAGE_PREFIX)) return; const value = readHeader(carrier, getter, k); - baggage = baggage.setEntry(k.substr(OT_BAGGAGE_PREFIX.length), { + baggage = baggage.setEntry(k.substring(OT_BAGGAGE_PREFIX.length), { value, }); });