@sebspark/otel 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -51,11 +51,11 @@ Automatically:
51
51
  ### Logging
52
52
 
53
53
  ```ts
54
- // Will throw if OTEL is not yet initialized
55
54
  import { getLogger } from '@sebspark/otel'
56
55
 
57
56
  const logger = getLogger()
58
57
 
58
+ // Will throw if OTEL is not yet initialized
59
59
  logger.debug('debug message')
60
60
  logger.info('something happened')
61
61
  logger.warn('almost bad')
package/dist/index.js CHANGED
@@ -791,15 +791,15 @@ async function _initialize(instrumentations2) {
791
791
 
792
792
  // src/logger.ts
793
793
  function getLogger(serviceOverride, extraAttrs = {}) {
794
- if (!isInitialized()) {
795
- throw new Error("OTEL must be initialized before calling getLogger()");
796
- }
797
794
  const { systemName, systemVersion, resourceAttributes } = detectTelemetryContext(serviceOverride);
798
795
  const defaultAttrs = {
799
796
  ...resourceAttributes,
800
797
  ...extraAttrs
801
798
  };
802
799
  function emit(severityText, body, attrs = {}) {
800
+ if (!isInitialized()) {
801
+ throw new Error("OTEL must be initialized before calling getLogger()");
802
+ }
803
803
  const logger = import_api_logs3.logs.getLogger(systemName, systemVersion);
804
804
  const span = import_api4.trace.getSpan(import_api4.context.active());
805
805
  const spanContext = span?.spanContext();
package/dist/index.mjs CHANGED
@@ -775,15 +775,15 @@ async function _initialize(instrumentations2) {
775
775
 
776
776
  // src/logger.ts
777
777
  function getLogger(serviceOverride, extraAttrs = {}) {
778
- if (!isInitialized()) {
779
- throw new Error("OTEL must be initialized before calling getLogger()");
780
- }
781
778
  const { systemName, systemVersion, resourceAttributes } = detectTelemetryContext(serviceOverride);
782
779
  const defaultAttrs = {
783
780
  ...resourceAttributes,
784
781
  ...extraAttrs
785
782
  };
786
783
  function emit(severityText, body, attrs = {}) {
784
+ if (!isInitialized()) {
785
+ throw new Error("OTEL must be initialized before calling getLogger()");
786
+ }
787
787
  const logger = logs2.getLogger(systemName, systemVersion);
788
788
  const span = trace2.getSpan(context.active());
789
789
  const spanContext = span?.spanContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/otel",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",