@jaypie/express 1.2.23 → 1.2.25

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/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { flushLlmObs, hasDatadogEnv, submitMetric, DATADOG, loadDatadogApiKey } from '@jaypie/datadog';
1
2
  import { Readable, Writable } from 'node:stream';
2
3
  import { ServerResponse } from 'node:http';
3
4
  import { CorsError, BadRequestError, UnhandledError, GatewayTimeoutError, UnavailableError, BadGatewayError, InternalError, TeapotError, GoneError, MethodNotAllowedError, NotFoundError, ForbiddenError, UnauthorizedError, NotImplementedError } from '@jaypie/errors';
@@ -5,7 +6,6 @@ import { force, envBoolean, JAYPIE, HTTP, getHeaderFrom, jaypieHandler } from '@
5
6
  import expressCors from 'cors';
6
7
  import { loadEnvSecrets, getContentTypeForFormat, formatStreamError } from '@jaypie/aws';
7
8
  import { log, redactAuth } from '@jaypie/logger';
8
- import { hasDatadogEnv, submitMetric, DATADOG } from '@jaypie/datadog';
9
9
 
10
10
  //
11
11
  //
@@ -1099,6 +1099,9 @@ function createLambdaHandler(app, _options) {
1099
1099
  finally {
1100
1100
  // Clear current invoke context
1101
1101
  clearCurrentInvoke();
1102
+ // Flush buffered LLM Observability spans before the Lambda freezes.
1103
+ // No-op unless DD_LLMOBS_ENABLED; never throws.
1104
+ flushLlmObs();
1102
1105
  }
1103
1106
  };
1104
1107
  }
@@ -1142,6 +1145,9 @@ function createLambdaStreamHandler(app, _options) {
1142
1145
  finally {
1143
1146
  // Clear current invoke context
1144
1147
  clearCurrentInvoke();
1148
+ // Flush buffered LLM Observability spans before the Lambda freezes.
1149
+ // No-op unless DD_LLMOBS_ENABLED; never throws.
1150
+ flushLlmObs();
1145
1151
  }
1146
1152
  });
1147
1153
  }
@@ -1863,6 +1869,10 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
1863
1869
  //
1864
1870
  // Build a request-local setup list to avoid mutating the shared array
1865
1871
  const requestSetup = [];
1872
+ // Load the Datadog LLM Observability API key into the environment when enabled
1873
+ requestSetup.push(async () => {
1874
+ await loadDatadogApiKey();
1875
+ });
1866
1876
  // Load secrets into process.env if configured
1867
1877
  if (secrets && secrets.length > 0) {
1868
1878
  const secretsToLoad = secrets;