@seeka-labs/sdk-apps-server-telemetry-logging 2.2.6
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/LICENSE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No license
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{OTLPLogExporter as _}from"@opentelemetry/exporter-logs-otlp-proto";import{HttpInstrumentation as d}from"@opentelemetry/instrumentation-http";import{UndiciInstrumentation as S}from"@opentelemetry/instrumentation-undici";import{WinstonInstrumentation as f}from"@opentelemetry/instrumentation-winston";import*as a from"@opentelemetry/api-logs";import{LoggerProvider as I,SimpleLogRecordProcessor as O}from"@opentelemetry/sdk-logs";import{resourceFromAttributes as T}from"@opentelemetry/resources";import{NodeSDK as g}from"@opentelemetry/sdk-node";import{ATTR_SERVICE_NAME as N,ATTR_SERVICE_VERSION as R}from"@opentelemetry/semantic-conventions";var e=null,l=null,i=null,h=(t,c,E,p,r,u)=>{let o=T({[N]:t,[R]:c,"service.namespace":"devapp","service.instance.id":r.WEBSITE_ROLE_INSTANCE_ID,"faas.name":r.WEBSITE_SITE_NAME,"faas.instance":r.WEBSITE_ROLE_INSTANCE_ID,"faas.version":r.OTEL_SERVICE_VERSION,"deployment.environment":r.NODE_ENV,"cloud.region":r.REGION_NAME,"cloud.provider":E,"cloud.platform":p,"seeka.app.id":process.env.SEEKA_APP_ID?.replace(/-/g,""),"seeka.app.name":t,...u});if(process.env.OTEL_SDK_DISABLED==="true")return o;if(e)return console.warn("[otel] OpenTelemetry SDK already started"),o;let m=process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT||process.env.OTEL_EXPORTER_OTLP_ENDPOINT||(process.env.LOGGING_SEQ_SERVERURL?process.env.LOGGING_SEQ_SERVERURL+"/ingest/otlp/v1/logs":void 0);l=new _({url:m,headers:{...process.env.LOGGING_SEQ_APIKEY?{"X-Seq-ApiKey":process.env.LOGGING_SEQ_APIKEY}:{}}}),i=new I({resource:o,processors:[new O(l)]}),a.logs.setGlobalLoggerProvider(i),e=new g({resource:o,instrumentations:[new f,new S,new d]});try{e.start(),process.env.NODE_ENV!=="production"&&console.log("[otel] OpenTelemetry SDK started")}catch(n){console.error("[otel] OpenTelemetry SDK failed to start",n)}let s=async()=>{try{if(!e)return;await e.shutdown(),console.log("[otel] OpenTelemetry SDK shut down")}catch(n){console.error("[otel] Error during OpenTelemetry shutdown",n)}};return process.on("SIGTERM",s),process.on("SIGINT",s),o},K=async()=>{try{e&&typeof e.forceFlush=="function"&&await e.forceFlush()}catch(t){console.error("[otel] forceFlush failed",t)}};export{K as forceFlushOpenTelemetry,h as registerSeekaAppOpenTelemetry};
|
|
2
|
+
//# sourceMappingURL=sdk-apps-server-telemetry-logging.module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/telemetry/register.ts"],
|
|
4
|
+
"sourcesContent": ["\nimport {OTLPLogExporter} from '@opentelemetry/exporter-logs-otlp-proto';\n// import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-proto';\nimport {HttpInstrumentation} from '@opentelemetry/instrumentation-http';\nimport {UndiciInstrumentation} from '@opentelemetry/instrumentation-undici';\nimport {WinstonInstrumentation} from '@opentelemetry/instrumentation-winston';\nimport * as logsAPI from '@opentelemetry/api-logs';\n\nimport {LoggerProvider, SimpleLogRecordProcessor} from '@opentelemetry/sdk-logs';\n\nimport {type Resource, resourceFromAttributes} from '@opentelemetry/resources';\nimport {NodeSDK} from '@opentelemetry/sdk-node';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\n\nlet sdk: NodeSDK | null = null;\n// let traceExporter: OTLPTraceExporter | null = null;\nlet logsExporter: OTLPLogExporter | null = null;\nlet loggerProvider: LoggerProvider | null = null;\n\nexport const registerSeekaAppOpenTelemetry = (\n appName: string, appVersion: string,\n cloudProvider: 'azure' | 'netlify' | 'aws' | string,\n cloudPlatform: 'azure_function' | 'netlify_function' | 'aws_lambda' | string, processEnv: NodeJS.ProcessEnv,\n resourceAttributes?: Record<string, any>\n): Resource => {\n\n const resource = resourceFromAttributes({\n [ATTR_SERVICE_NAME]: appName,\n [ATTR_SERVICE_VERSION]: appVersion,\n 'service.namespace': 'devapp',\n 'service.instance.id': processEnv.WEBSITE_ROLE_INSTANCE_ID,\n 'faas.name': processEnv.WEBSITE_SITE_NAME,\n 'faas.instance': processEnv.WEBSITE_ROLE_INSTANCE_ID,\n 'faas.version': processEnv.OTEL_SERVICE_VERSION,\n 'deployment.environment': processEnv.NODE_ENV,\n 'cloud.region': processEnv.REGION_NAME,\n 'cloud.provider': cloudProvider,\n 'cloud.platform': cloudPlatform,\n 'seeka.app.id': process.env.SEEKA_APP_ID?.replace(/-/g, ''),\n 'seeka.app.name': appName,\n ...resourceAttributes\n })\n\n // Respect OTEL_SDK_DISABLED=true to skip initialization\n if (process.env.OTEL_SDK_DISABLED === 'true') return resource\n\n if (sdk) {\n console.warn('[otel] OpenTelemetry SDK already started');\n return resource;\n }\n\n // const tracesUrl = process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || (process.env.LOGGING_SEQ_SERVERURL ? process.env.LOGGING_SEQ_SERVERURL + '/ingest/otlp/v1/traces' : undefined);\n\n // traceExporter = new OTLPTraceExporter({\n // url: tracesUrl,\n // headers: {\n // ...(process.env.LOGGING_SEQ_APIKEY ? {'X-Seq-ApiKey': process.env.LOGGING_SEQ_APIKEY} : {}),\n // },\n // });\n\n // const tracerProvider = new NodeTracerProvider({\n // resource,\n // spanProcessors: [\n // new SimpleSpanProcessor(traceExporter)\n // ]\n // });\n // tracerProvider.register();\n\n // Logs must be sent to the OTLP logs endpoint, not the traces endpoint\n const logsUrl = process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || (process.env.LOGGING_SEQ_SERVERURL ? process.env.LOGGING_SEQ_SERVERURL + '/ingest/otlp/v1/logs' : undefined);\n\n // console.log('[otel] Logs exporter URL:', logsUrl);\n logsExporter = new OTLPLogExporter({\n url: logsUrl,\n headers: {\n ...(process.env.LOGGING_SEQ_APIKEY ? {'X-Seq-ApiKey': process.env.LOGGING_SEQ_APIKEY} : {}),\n }\n });\n\n loggerProvider = new LoggerProvider({\n resource,\n processors: [new SimpleLogRecordProcessor(logsExporter)]\n });\n logsAPI.logs.setGlobalLoggerProvider(loggerProvider);\n\n sdk = new NodeSDK({\n resource,\n // Capture outgoing and incoming HTTP spans. Outgoing covers axios/gaxios/etc via core http/https.\n instrumentations: [\n new WinstonInstrumentation(),\n // new NetInstrumentation(),\n new UndiciInstrumentation(),\n // new IORedisInstrumentation(),\n // new AzureFunctionsInstrumentation(),\n new HttpInstrumentation(),\n // Capture HTTP/2 (used under the hood by grpc-js)\n // new Http2Instrumentation(),\n // Capture RPC spans for gRPC (@grpc/grpc-js)\n // new GrpcInstrumentation()\n ],\n // logRecordProcessors: [\n // new SimpleLogRecordProcessor(logsExporter)\n // ],\n // spanProcessors: [\n // new SimpleSpanProcessor(traceExporter)\n // ],\n // Export traces via OTLP; configure endpoint/headers via OTEL_EXPORTER_OTLP_* env vars\n // traceExporter\n });\n\n // Start immediately; Azure Functions worker loads this before function code\n try {\n // Note: in recent SDK versions start() may be synchronous\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sdk.start();\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.log('[otel] OpenTelemetry SDK started');\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('[otel] OpenTelemetry SDK failed to start', err);\n }\n\n const shutdown = async () => {\n try {\n if (!sdk) return;\n await sdk.shutdown();\n // eslint-disable-next-line no-console\n console.log('[otel] OpenTelemetry SDK shut down');\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('[otel] Error during OpenTelemetry shutdown', err);\n }\n };\n\n process.on('SIGTERM', shutdown);\n process.on('SIGINT', shutdown);\n\n return resource;\n}\n\nexport const forceFlushOpenTelemetry = async (): Promise<void> => {\n try {\n if (sdk && typeof (sdk as any).forceFlush === 'function') {\n await (sdk as any).forceFlush();\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('[otel] forceFlush failed', err);\n }\n};\n"],
|
|
5
|
+
"mappings": "AACA,OAAQ,mBAAAA,MAAsB,0CAE9B,OAAQ,uBAAAC,MAA0B,sCAClC,OAAQ,yBAAAC,MAA4B,wCACpC,OAAQ,0BAAAC,MAA6B,yCACrC,UAAYC,MAAa,0BAEzB,OAAQ,kBAAAC,EAAgB,4BAAAC,MAA+B,0BAEvD,OAAuB,0BAAAC,MAA6B,2BACpD,OAAQ,WAAAC,MAAc,0BACtB,OACI,qBAAAC,EACA,wBAAAC,MACG,sCAEP,IAAIC,EAAsB,KAEtBC,EAAuC,KACvCC,EAAwC,KAE/BC,EAAgC,CACzCC,EAAiBC,EACjBC,EACAC,EAA8EC,EAC9EC,IACW,CAEX,IAAMC,EAAWd,EAAuB,CACpC,CAACE,CAAiB,EAAGM,EACrB,CAACL,CAAoB,EAAGM,EACxB,oBAAqB,SACrB,sBAAuBG,EAAW,yBAClC,YAAaA,EAAW,kBACxB,gBAAiBA,EAAW,yBAC5B,eAAgBA,EAAW,qBAC3B,yBAA0BA,EAAW,SACrC,eAAgBA,EAAW,YAC3B,iBAAkBF,EAClB,iBAAkBC,EAClB,eAAgB,QAAQ,IAAI,cAAc,QAAQ,KAAM,EAAE,EAC1D,iBAAkBH,EAClB,GAAGK,CACP,CAAC,EAGD,GAAI,QAAQ,IAAI,oBAAsB,OAAQ,OAAOC,EAErD,GAAIV,EACA,eAAQ,KAAK,0CAA0C,EAChDU,EAqBX,IAAMC,EAAU,QAAQ,IAAI,kCAAoC,QAAQ,IAAI,8BAAgC,QAAQ,IAAI,sBAAwB,QAAQ,IAAI,sBAAwB,uBAAyB,QAG7MV,EAAe,IAAIZ,EAAgB,CAC/B,IAAKsB,EACL,QAAS,CACL,GAAI,QAAQ,IAAI,mBAAqB,CAAC,eAAgB,QAAQ,IAAI,kBAAkB,EAAI,CAAC,CAC7F,CACJ,CAAC,EAEDT,EAAiB,IAAIR,EAAe,CAChC,SAAAgB,EACA,WAAY,CAAC,IAAIf,EAAyBM,CAAY,CAAC,CAC3D,CAAC,EACO,OAAK,wBAAwBC,CAAc,EAEnDF,EAAM,IAAIH,EAAQ,CACd,SAAAa,EAEA,iBAAkB,CACd,IAAIlB,EAEJ,IAAID,EAGJ,IAAID,CAKR,CASJ,CAAC,EAGD,GAAI,CAIAU,EAAI,MAAM,EACN,QAAQ,IAAI,WAAa,cAEzB,QAAQ,IAAI,kCAAkC,CAEtD,OAASY,EAAK,CAEV,QAAQ,MAAM,2CAA4CA,CAAG,CACjE,CAEA,IAAMC,EAAW,SAAY,CACzB,GAAI,CACA,GAAI,CAACb,EAAK,OACV,MAAMA,EAAI,SAAS,EAEnB,QAAQ,IAAI,oCAAoC,CACpD,OAASY,EAAK,CAEV,QAAQ,MAAM,6CAA8CA,CAAG,CACnE,CACJ,EAEA,eAAQ,GAAG,UAAWC,CAAQ,EAC9B,QAAQ,GAAG,SAAUA,CAAQ,EAEtBH,CACX,EAEaI,EAA0B,SAA2B,CAC9D,GAAI,CACId,GAAO,OAAQA,EAAY,YAAe,YAC1C,MAAOA,EAAY,WAAW,CAEtC,OAASY,EAAK,CAEV,QAAQ,MAAM,2BAA4BA,CAAG,CACjD,CACJ",
|
|
6
|
+
"names": ["OTLPLogExporter", "HttpInstrumentation", "UndiciInstrumentation", "WinstonInstrumentation", "logsAPI", "LoggerProvider", "SimpleLogRecordProcessor", "resourceFromAttributes", "NodeSDK", "ATTR_SERVICE_NAME", "ATTR_SERVICE_VERSION", "sdk", "logsExporter", "loggerProvider", "registerSeekaAppOpenTelemetry", "appName", "appVersion", "cloudProvider", "cloudPlatform", "processEnv", "resourceAttributes", "resource", "logsUrl", "err", "shutdown", "forceFlushOpenTelemetry"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './telemetry/register';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Resource } from '@opentelemetry/resources';
|
|
2
|
+
export declare const registerSeekaAppOpenTelemetry: (appName: string, appVersion: string, cloudProvider: "azure" | "netlify" | "aws" | string, cloudPlatform: "azure_function" | "netlify_function" | "aws_lambda" | string, processEnv: NodeJS.ProcessEnv, resourceAttributes?: Record<string, any>) => Resource;
|
|
3
|
+
export declare const forceFlushOpenTelemetry: () => Promise<void>;
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seeka-labs/sdk-apps-server-telemetry-logging",
|
|
3
|
+
"version": "2.2.6",
|
|
4
|
+
"description": "Seeka - Apps SDK - Server Telemetry Logging (App health and logging)",
|
|
5
|
+
"author": "SEEKA <platform@seeka.co>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"apps",
|
|
9
|
+
"seeka",
|
|
10
|
+
"telemetry",
|
|
11
|
+
"opentelemetry",
|
|
12
|
+
"metrics"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"type": "module",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"main": "./dist/lib/sdk-apps-server-telemetry-logging.module.js",
|
|
24
|
+
"module": "./dist/lib/sdk-apps-server-telemetry-logging.module.js",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"clean": "rimraf build package dist",
|
|
27
|
+
"build": "yarn esbuild src/index.ts --outfile=dist/lib/sdk-apps-server-telemetry-logging.module.js --bundle --analyze --platform=node --format=esm --packages=external --minify --sourcemap && yarn tsc --emitDeclarationOnly",
|
|
28
|
+
"dev": "yarn esbuild src/index.ts --outfile=dist/lib/sdk-apps-server-telemetry-logging.module.js --bundle --analyze --platform=node --format=esm --packages=external --sourcemap && yarn tsc --emitDeclarationOnly",
|
|
29
|
+
"build:ci": "yarn run build",
|
|
30
|
+
"test": "ava"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@opentelemetry/api": "*",
|
|
34
|
+
"@opentelemetry/exporter-logs-otlp-proto": "*",
|
|
35
|
+
"@opentelemetry/exporter-trace-otlp-proto": "*",
|
|
36
|
+
"@opentelemetry/instrumentation-grpc": "*",
|
|
37
|
+
"@opentelemetry/instrumentation-http": "*",
|
|
38
|
+
"@opentelemetry/instrumentation-ioredis": "*",
|
|
39
|
+
"@opentelemetry/instrumentation-net": "*",
|
|
40
|
+
"@opentelemetry/instrumentation-undici": "*",
|
|
41
|
+
"@opentelemetry/instrumentation-winston": "*",
|
|
42
|
+
"@opentelemetry/sdk-node": "*",
|
|
43
|
+
"@opentelemetry/sdk-trace-node": "*",
|
|
44
|
+
"@opentelemetry/winston-transport": "*",
|
|
45
|
+
"@seeka-labs/sdk-apps-server": "^2",
|
|
46
|
+
"axios": "^1",
|
|
47
|
+
"memory-cache": "^0",
|
|
48
|
+
"openid-client": "^6",
|
|
49
|
+
"undici": "^7",
|
|
50
|
+
"winston": "^3"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"jwt-decode": "^4"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@babel/core": "^7",
|
|
57
|
+
"@babel/preset-env": "^7",
|
|
58
|
+
"@babel/preset-typescript": "^7",
|
|
59
|
+
"@opentelemetry/api": "^1.9.0",
|
|
60
|
+
"@opentelemetry/exporter-logs-otlp-proto": "^0.207.0",
|
|
61
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.207.0",
|
|
62
|
+
"@opentelemetry/instrumentation-grpc": "^0.207.0",
|
|
63
|
+
"@opentelemetry/instrumentation-http": "^0.207.0",
|
|
64
|
+
"@opentelemetry/instrumentation-ioredis": "^0.55.0",
|
|
65
|
+
"@opentelemetry/instrumentation-net": "^0.51.0",
|
|
66
|
+
"@opentelemetry/instrumentation-undici": "^0.18.0",
|
|
67
|
+
"@opentelemetry/instrumentation-winston": "^0.52.0",
|
|
68
|
+
"@opentelemetry/sdk-node": "^0.207.0",
|
|
69
|
+
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
|
70
|
+
"@opentelemetry/winston-transport": "^0.18.0",
|
|
71
|
+
"@seeka-labs/sdk-apps-server": "2.2.6",
|
|
72
|
+
"@types/node": "^24",
|
|
73
|
+
"ava": "^6",
|
|
74
|
+
"axios": "^1",
|
|
75
|
+
"cross-env": "^10",
|
|
76
|
+
"dotenv": "^17",
|
|
77
|
+
"esbuild": "^0",
|
|
78
|
+
"memory-cache": "^0",
|
|
79
|
+
"openid-client": "^6",
|
|
80
|
+
"rimraf": "^6",
|
|
81
|
+
"tsx": "^4",
|
|
82
|
+
"typescript": "^5",
|
|
83
|
+
"undici": "^7",
|
|
84
|
+
"winston": "^3"
|
|
85
|
+
},
|
|
86
|
+
"gitHead": "7cb859a39dc4f1c1a447ae2cf0eb8b1a57aa54cd"
|
|
87
|
+
}
|