Determine the appropriate semconv stability for the given namespace.
This will parse the given string of comma-separated values (often
process.env.OTEL_SEMCONV_STABILITY_OPT_IN) looking for the ${namespace}
or ${namespace}/dup tokens. This is a pattern defined by a number of
non-normative semconv documents.
// When supporting the OTEL_SEMCONV_STABILITY_OPT_IN envvar
this._semconvStability = semconvStabilityFromStr(
'http',
process.env.OTEL_SEMCONV_STABILITY_OPT_IN
);
// or when supporting a `semconvStabilityOptIn` config option (e.g. for
// the web where there are no envvars).
this._semconvStability = semconvStabilityFromStr(
'http',
config?.semconvStabilityOptIn
);
}
}
// Then, to apply semconv, use the following or similar:
if (this._semconvStability & SemconvStability.OLD) {
// ...
}
if (this._semconvStability & SemconvStability.STABLE) {
// ...
}
Determine the appropriate semconv stability for the given namespace.
This will parse the given string of comma-separated values (often
process.env.OTEL_SEMCONV_STABILITY_OPT_IN
) looking for the${namespace}
or${namespace}/dup
tokens. This is a pattern defined by a number of non-normative semconv documents.For example:
Usage:
import {SemconvStability, semconvStabilityFromStr} from '@opentelemetry/instrumentation';
export class FooInstrumentation extends InstrumentationBase {
private _semconvStability: SemconvStability;
constructor(config: FooInstrumentationConfig = {}) {
super('@opentelemetry/instrumentation-foo', VERSION, config);
} }
// Then, to apply semconv, use the following or similar: if (this._semconvStability & SemconvStability.OLD) { // ... } if (this._semconvStability & SemconvStability.STABLE) { // ... }