Skip to content

Commit

Permalink
remove flag for this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
maryliag committed Oct 16, 2024
1 parent 219a76b commit 64a407f
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 59 deletions.
17 changes: 0 additions & 17 deletions plugins/node/opentelemetry-instrumentation-pg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@ PostgreSQL instrumentation has few options available to choose from. You can set
| `requireParentSpan` | `boolean` | If true, requires a parent span to create new spans (default false) |
| `addSqlCommenterCommentToQueries` | `boolean` | If true, adds [sqlcommenter](https:/open-telemetry/opentelemetry-sqlcommenter) specification compliant comment to queries with tracing context (default false). _NOTE: A comment will not be added to queries that already contain `--` or `/* ... */` in them, even if these are not actually part of comments_ |

### Metrics

The value of the environment variable `OTEL_SEMCONV_STABILITY_OPT_IN` (a comma-separated list of values) will define which metrics are being collected.
Possible values:

- `database` - emit the new database conventions and stop emitting old database conventions.
- `database/dup` - emit both the old and the stable database conventions, allowing for a seamless transition.
- The default behavior (in the absence of one of these values) is to continue emitting only the old database conventions.

List of Metrics affected by this environment variable (if the metric is not listed here, it will always be emitted):

| Metric | Emitted with value of `OTEL_SEMCONV_STABILITY_OPT_IN` |
| --------------------------------------- | ---------------------------- |
| `db.client.operation.duration` | `database` or `database/dup` |
| `db.client.connection.count` | `database` or `database/dup` |
| `db.client.connection.pending_requests` | `database` or `database/dup` |

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
}

override _updateMetricInstruments() {
const emit = utils.getEmitType();
if (emit === utils.emitType.OLD_SEM_CONV) return;
this._operationDuration = this.meter.createHistogram(
METRIC_DB_CLIENT_OPERATION_DURATION,
{
Expand Down Expand Up @@ -225,8 +223,6 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
}

private recordOperationDuration(attributes: Attributes, startTime: HrTime) {
const emit = utils.getEmitType();
if (emit === utils.emitType.OLD_SEM_CONV) return;
const metricsAttributes: Attributes = {};
const keysToCopy = [
SEMATTRS_DB_SYSTEM,
Expand Down Expand Up @@ -441,8 +437,6 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
}

private _setPoolConnectEventListeners(pgPool: PgPoolExtended) {
const emit = utils.getEmitType();
if (emit === utils.emitType.OLD_SEM_CONV) return;
if (pgPool[EVENT_LISTENERS_SET]) return;
const poolName = utils.getPoolName(pgPool.options);

Expand Down
16 changes: 0 additions & 16 deletions plugins/node/opentelemetry-instrumentation-pg/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ import type * as pgTypes from 'pg';
import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
import { SpanNames } from './enums/SpanNames';

export enum emitType {
NEW_SEM_CONV,
OLD_SEM_CONV,
BOTH_SEM_CONV,
}

export function getEmitType(): emitType {
if (process.env.OTEL_SEMCONV_STABILITY_OPT_IN?.includes('database/dup')) {
return emitType.BOTH_SEM_CONV;
}
if (process.env.OTEL_SEMCONV_STABILITY_OPT_IN?.includes('database')) {
return emitType.NEW_SEM_CONV;
}
return emitType.OLD_SEM_CONV;
}

/**
* Helper function to get a low cardinality span name from whatever info we have
* about the query.
Expand Down
10 changes: 0 additions & 10 deletions plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,22 +490,12 @@ describe('pg-pool', () => {
});

describe('pg metrics', () => {
let envOptIn: string | undefined;
let metricReader: testUtils.TestMetricReader;

beforeEach(() => {
metricReader = testUtils.initMeterProvider(instrumentation);
});

before(() => {
envOptIn = process.env.OTEL_SEMCONV_STABILITY_OPT_IN;
process.env.OTEL_SEMCONV_STABILITY_OPT_IN = 'database';
});

after(function () {
process.env.OTEL_SEMCONV_STABILITY_OPT_IN = envOptIn;
});

it('should generate `db.client.connection.count` and `db.client.connection.pending_requests` metrics', done => {
pool.connect((err, client, release) => {
if (err) {
Expand Down
10 changes: 0 additions & 10 deletions plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,22 +968,12 @@ describe('pg', () => {
});

describe('pg metrics', () => {
let envOptIn: string | undefined;
let metricReader: testUtils.TestMetricReader;

beforeEach(() => {
metricReader = testUtils.initMeterProvider(instrumentation);
});

before(() => {
envOptIn = process.env.OTEL_SEMCONV_STABILITY_OPT_IN;
process.env.OTEL_SEMCONV_STABILITY_OPT_IN = 'database';
});

after(function () {
process.env.OTEL_SEMCONV_STABILITY_OPT_IN = envOptIn;
});

it('should generate db.client.operation.duration metric', done => {
client.query('SELECT NOW()', async (_, ret) => {
assert.ok(ret, 'query should be executed');
Expand Down

0 comments on commit 64a407f

Please sign in to comment.