otlp-logger 1.1.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/LICENSE +21 -0
- package/README.md +122 -0
- package/commitlint.config.js +6 -0
- package/lib/create-log-processor.js +94 -0
- package/lib/multi-log-processor.js +38 -0
- package/lib/otlp-logger.js +102 -0
- package/package.json +64 -0
- package/types/create-log-processor.d.ts +30 -0
- package/types/create-log-processor.d.ts.map +1 -0
- package/types/multi-log-processor.d.ts +13 -0
- package/types/multi-log-processor.d.ts.map +1 -0
- package/types/otlp-logger.d.ts +23 -0
- package/types/otlp-logger.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Vladimir Adamić
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# otlp-logger
|
|
2
|
+
[](https://www.npmjs.com/package/otlp-logger)
|
|
3
|
+
[](https://standardjs.com/)
|
|
4
|
+
|
|
5
|
+
Sends logs in the [OpenTelemetry Log Data Model](https://github.com/open-telemetry/opentelemetry-specification/blob/fc8289b8879f3a37e1eba5b4e445c94e74b20359/specification/logs/data-model.md) to an OTLP logs collector.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm i otlp-logger
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
### Protocol
|
|
15
|
+
can be set to `http/protobuf`, `grpc`, `http` or `console` by using
|
|
16
|
+
|
|
17
|
+
* env var `OTEL_EXPORTER_OTLP_PROTOCOL`
|
|
18
|
+
* env var `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL`
|
|
19
|
+
* setting the exporterProtocol option
|
|
20
|
+
|
|
21
|
+
Settings configured programmatically take precedence over environment variables. Per-signal environment variables take precedence over non-per-signal environment variables. This principle applies to all the configurations in this module.
|
|
22
|
+
|
|
23
|
+
If no protocol is specified, `http/protobuf` is used as a default.
|
|
24
|
+
|
|
25
|
+
### Exporter settings
|
|
26
|
+
|
|
27
|
+
#### Collector URL
|
|
28
|
+
|
|
29
|
+
Set either of the following environment variables:
|
|
30
|
+
`OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`,
|
|
31
|
+
`OTEL_EXPORTER_OTLP_ENDPOINT`
|
|
32
|
+
|
|
33
|
+
#### Protocol-specific exporter configuration
|
|
34
|
+
|
|
35
|
+
#### `http/protobuf`
|
|
36
|
+
[Env vars in README](https://github.com/open-telemetry/opentelemetry-js/blob/d4a41bd815dd50703f692000a70c59235ad71959/experimental/packages/exporter-trace-otlp-proto/README.md#exporter-timeout-configuration)
|
|
37
|
+
|
|
38
|
+
#### `grpc`
|
|
39
|
+
[Environment Variable Configuration](https://github.com/open-telemetry/opentelemetry-js/blob/d4a41bd815dd50703f692000a70c59235ad71959/experimental/packages/exporter-logs-otlp-grpc/README.md#environment-variable-configuration)
|
|
40
|
+
|
|
41
|
+
#### `http`
|
|
42
|
+
[Env vars in README](https://github.com/open-telemetry/opentelemetry-js/blob/d4a41bd815dd50703f692000a70c59235ad71959/experimental/packages/exporter-trace-otlp-http/README.md#configuration-options-as-environment-variables)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
#### Processor-specific configuration
|
|
46
|
+
If batch log processor is selected (is default), it can be configured using env vars described in the [OpenTelemetry specification](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#batch-logrecord-processor)
|
|
47
|
+
|
|
48
|
+
### Options
|
|
49
|
+
When using the transport, the following options can be used to configure the transport programmatically:
|
|
50
|
+
|
|
51
|
+
* `loggerName`: name to be used by the OpenTelemetry logger
|
|
52
|
+
* `serviceVersion`: name to be used by the OpenTelemetry logger
|
|
53
|
+
* `resourceAttributes`: Object containing [resource attributes](https://opentelemetry.io/docs/instrumentation/js/resources/). Optional
|
|
54
|
+
* `logRecordProcessorOptions`: a single object or an array of objects specifying the LogProcessor and LogExporter types and constructor params. Optional
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### Minimalistic example
|
|
60
|
+
|
|
61
|
+
Make sure you have access to an OTEL collector.
|
|
62
|
+
|
|
63
|
+
To start quickly, create a minimal configuration for OTEL collector in the `otel-collector-config.yaml` file:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
receivers:
|
|
67
|
+
otlp:
|
|
68
|
+
protocols:
|
|
69
|
+
grpc:
|
|
70
|
+
|
|
71
|
+
exporters:
|
|
72
|
+
file:
|
|
73
|
+
path: ./etc/test-logs/otlp-logs.log
|
|
74
|
+
flush_interval: 1
|
|
75
|
+
|
|
76
|
+
logging:
|
|
77
|
+
verbosity: basic
|
|
78
|
+
|
|
79
|
+
processors:
|
|
80
|
+
batch:
|
|
81
|
+
|
|
82
|
+
service:
|
|
83
|
+
pipelines:
|
|
84
|
+
logs:
|
|
85
|
+
receivers: [otlp]
|
|
86
|
+
processors: []
|
|
87
|
+
exporters: [logging, file]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The collector can then be ran with:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
docker run --volume=$(pwd)/otel-collector-config.yaml:/etc/otel-collector-config.yaml:rw --volume=/tmp/test-logs:/etc/test-logs:rw -p 4317:4317 -d otel/opentelemetry-collector-contrib:latest --config=/etc/otel-collector-config.yaml
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Create an index.js file containing
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
const { getOtlpLogger } = require('otlp-logger')
|
|
100
|
+
|
|
101
|
+
const logger = getOtlpLogger({
|
|
102
|
+
loggerName: 'test',
|
|
103
|
+
serviceVersion: '1.0.0'
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
logger.emit({
|
|
107
|
+
severityNumber: 1,
|
|
108
|
+
severityText: 'TRACE',
|
|
109
|
+
body: 'test',
|
|
110
|
+
timestamp: Date.now()
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Run the service setting the `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` and `OTEL_RESOURCE_ATTRIBUTES` env vars
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL='grpc' OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4317 OTEL_RESOURCE_ATTRIBUTES="service.name=my-service,service.version=1.2.3" node index.js
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
SimpleLogRecordProcessor,
|
|
5
|
+
BatchLogRecordProcessor,
|
|
6
|
+
ConsoleLogRecordExporter
|
|
7
|
+
} = require('@opentelemetry/sdk-logs')
|
|
8
|
+
|
|
9
|
+
const { MultiLogRecordProcessor } = require('./multi-log-processor')
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {LogRecordProcessorOptions | LogRecordProcessorOptions[]} [logRecordProcessorOptions]
|
|
13
|
+
*/
|
|
14
|
+
function createLogProcessor (logRecordProcessorOptions) {
|
|
15
|
+
return Array.isArray(logRecordProcessorOptions)
|
|
16
|
+
? new MultiLogRecordProcessor(
|
|
17
|
+
logRecordProcessorOptions.map(createLogRecordProcessor)
|
|
18
|
+
)
|
|
19
|
+
: createLogRecordProcessor(logRecordProcessorOptions)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {"batch" | "simple"} RecordProcessorType
|
|
24
|
+
* @typedef {Object} LogRecordProcessorOptions
|
|
25
|
+
* @property {RecordProcessorType} recordProcessorType = "batch"
|
|
26
|
+
* @property {ExporterOptions} [exporterOptions]
|
|
27
|
+
* @property {import('@opentelemetry/sdk-logs').BufferConfig} [processorConfig]
|
|
28
|
+
*
|
|
29
|
+
* @param {LogRecordProcessorOptions} [opts]
|
|
30
|
+
* @returns {import('@opentelemetry/sdk-logs').LogRecordProcessor}
|
|
31
|
+
*/
|
|
32
|
+
function createLogRecordProcessor (opts) {
|
|
33
|
+
const exporter = createExporter(opts?.exporterOptions)
|
|
34
|
+
|
|
35
|
+
if (opts?.recordProcessorType === 'simple') {
|
|
36
|
+
return new SimpleLogRecordProcessor(exporter)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return new BatchLogRecordProcessor(exporter, opts?.processorConfig)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} GrpcExporterOptions
|
|
44
|
+
* @property {"grpc"} protocol
|
|
45
|
+
* @property {import('@opentelemetry/otlp-grpc-exporter-base').OTLPGRPCExporterConfigNode} [grpcExporterOptions]
|
|
46
|
+
*
|
|
47
|
+
* @typedef {Object} HttpExporterOptions
|
|
48
|
+
* @property {"http"} protocol
|
|
49
|
+
* @property {import('@opentelemetry/otlp-exporter-base').OTLPExporterNodeConfigBase} [httpExporterOptions]
|
|
50
|
+
*
|
|
51
|
+
* @typedef {Object} ProtobufExporterOptions
|
|
52
|
+
* @property {"http/protobuf"} protocol
|
|
53
|
+
* @property {import('@opentelemetry/otlp-exporter-base').OTLPExporterNodeConfigBase} [protobufExporterOptions]
|
|
54
|
+
*
|
|
55
|
+
* @typedef {Object} ConsoleExporterOptions
|
|
56
|
+
* @property {"console"} protocol
|
|
57
|
+
*
|
|
58
|
+
* @typedef {GrpcExporterOptions | HttpExporterOptions | ProtobufExporterOptions | ConsoleExporterOptions } ExporterOptions
|
|
59
|
+
*
|
|
60
|
+
* @param {ExporterOptions} exporterOptions
|
|
61
|
+
* @returns {import('@opentelemetry/sdk-logs').LogRecordExporter}
|
|
62
|
+
*/
|
|
63
|
+
function createExporter (exporterOptions) {
|
|
64
|
+
const exporterProtocol =
|
|
65
|
+
exporterOptions?.protocol ??
|
|
66
|
+
process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL ??
|
|
67
|
+
process.env.OTEL_EXPORTER_OTLP_PROTOCOL
|
|
68
|
+
|
|
69
|
+
if (exporterProtocol === 'grpc') {
|
|
70
|
+
const {
|
|
71
|
+
OTLPLogExporter
|
|
72
|
+
} = require('@opentelemetry/exporter-logs-otlp-grpc')
|
|
73
|
+
return new OTLPLogExporter(exporterOptions?.grpcExporterOptions)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (exporterProtocol === 'http') {
|
|
77
|
+
const {
|
|
78
|
+
OTLPLogExporter
|
|
79
|
+
} = require('@opentelemetry/exporter-logs-otlp-http')
|
|
80
|
+
return new OTLPLogExporter(exporterOptions?.httpExporterOptions)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (exporterProtocol === 'console') {
|
|
84
|
+
return new ConsoleLogRecordExporter()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const { OTLPLogExporter } = require('@opentelemetry/exporter-logs-otlp-proto')
|
|
88
|
+
|
|
89
|
+
return new OTLPLogExporter(exporterOptions?.protobufExporterOptions)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
createLogProcessor
|
|
94
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use_strict'
|
|
2
|
+
|
|
3
|
+
const { callWithTimeout } = require('@opentelemetry/core')
|
|
4
|
+
|
|
5
|
+
// taken from https://github.com/open-telemetry/opentelemetry-js/blob/5fcd8cf136e2235903dde3df9ba03ced594f0e95/experimental/packages/sdk-logs/src/types.ts#L27C3-L27C26
|
|
6
|
+
const FORCE_FLUSH_TIMEOUT_MILLIS = 30000
|
|
7
|
+
/**
|
|
8
|
+
* Using the MultiLogRecordProcessor from the sdk-logs package is currently not possible because it is not exported.
|
|
9
|
+
* This should work as a drop-in replacement.
|
|
10
|
+
*/
|
|
11
|
+
class MultiLogRecordProcessor {
|
|
12
|
+
constructor (processors, forceFlushTimeoutMillis) {
|
|
13
|
+
this.processors = processors
|
|
14
|
+
this.forceFlushTimeoutMillis = forceFlushTimeoutMillis
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async forceFlush () {
|
|
18
|
+
const timeout = this.forceFlushTimeoutMillis
|
|
19
|
+
await Promise.all(
|
|
20
|
+
this.processors.map(processor =>
|
|
21
|
+
(FORCE_FLUSH_TIMEOUT_MILLIS, callWithTimeout)(
|
|
22
|
+
processor.forceFlush(),
|
|
23
|
+
timeout
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onEmit (logRecord) {
|
|
30
|
+
this.processors.forEach(processors => processors.onEmit(logRecord))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async shutdown () {
|
|
34
|
+
await Promise.all(this.processors.map(processor => processor.shutdown()))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.MultiLogRecordProcessor = MultiLogRecordProcessor
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { LoggerProvider } = require('@opentelemetry/sdk-logs')
|
|
4
|
+
const { logs } = require('@opentelemetry/api-logs') // TODO: optional import
|
|
5
|
+
const api = require('@opentelemetry/api')
|
|
6
|
+
const {
|
|
7
|
+
Resource,
|
|
8
|
+
detectResourcesSync,
|
|
9
|
+
envDetectorSync,
|
|
10
|
+
hostDetectorSync,
|
|
11
|
+
osDetectorSync,
|
|
12
|
+
processDetector
|
|
13
|
+
} = require('@opentelemetry/resources')
|
|
14
|
+
const { createLogProcessor } = require('./create-log-processor')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} Options
|
|
18
|
+
* @property {string} loggerName
|
|
19
|
+
* @property {string} serviceVersion
|
|
20
|
+
* @property {import('./create-log-processor').LogRecordProcessorOptions | import('./create-log-processor').LogRecordProcessorOptions[]} [logRecordProcessorOptions]
|
|
21
|
+
* @property {Object} [resourceAttributes={}]
|
|
22
|
+
*
|
|
23
|
+
* @param {Options} opts
|
|
24
|
+
*/
|
|
25
|
+
function getOtlpLogger (opts) {
|
|
26
|
+
const detectedResource = detectResourcesSync({
|
|
27
|
+
detectors: [
|
|
28
|
+
envDetectorSync,
|
|
29
|
+
hostDetectorSync,
|
|
30
|
+
osDetectorSync,
|
|
31
|
+
processDetector
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
const loggerProvider = new LoggerProvider({
|
|
35
|
+
resource: detectedResource.merge(
|
|
36
|
+
new Resource({ ...opts.resourceAttributes })
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
loggerProvider.addLogRecordProcessor(
|
|
41
|
+
createLogProcessor(opts.logRecordProcessorOptions)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
logs.setGlobalLoggerProvider(loggerProvider)
|
|
45
|
+
|
|
46
|
+
const logger = logs.getLogger(opts.loggerName, opts.serviceVersion)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
/**
|
|
50
|
+
* @param {import('@opentelemetry/api-logs').LogRecord} obj
|
|
51
|
+
*/
|
|
52
|
+
emit (obj) {
|
|
53
|
+
logger.emit(loadContext(obj))
|
|
54
|
+
},
|
|
55
|
+
async shutdown () {
|
|
56
|
+
return loggerProvider.shutdown()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* load context from attributes and set it to logRecord.context
|
|
63
|
+
*
|
|
64
|
+
* @param {import('@opentelemetry/api-logs').LogRecord} logRecord
|
|
65
|
+
* @returns {import('@opentelemetry/api-logs').LogRecord}
|
|
66
|
+
*/
|
|
67
|
+
function loadContext (logRecord) {
|
|
68
|
+
let context = api.context.active()
|
|
69
|
+
let attributes = logRecord.attributes
|
|
70
|
+
|
|
71
|
+
if (typeof attributes !== 'undefined') {
|
|
72
|
+
/* eslint-disable camelcase */
|
|
73
|
+
const { trace_id, span_id, trace_flags, ...otherAttributes } =
|
|
74
|
+
logRecord.attributes
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
typeof trace_id !== 'undefined' &&
|
|
78
|
+
typeof span_id !== 'undefined' &&
|
|
79
|
+
typeof trace_flags !== 'undefined'
|
|
80
|
+
) {
|
|
81
|
+
context = api.trace.setSpanContext(context, {
|
|
82
|
+
traceId: trace_id,
|
|
83
|
+
spanId: span_id,
|
|
84
|
+
traceFlags: trace_flags,
|
|
85
|
+
isRemote: true
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
attributes = otherAttributes
|
|
90
|
+
/* eslint-enable camelcase */
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
...logRecord,
|
|
95
|
+
attributes,
|
|
96
|
+
context
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = {
|
|
101
|
+
getOtlpLogger
|
|
102
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "otlp-logger",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Exports logs to OpenTelemetry Collector using OTLP protocol",
|
|
5
|
+
"main": "lib/otlp-logger.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"validate-and-test": "standard | snazzy && tap test/**/*.test.js --coverage-report=lcovonly && tsd",
|
|
8
|
+
"test": "npm run validate-and-test",
|
|
9
|
+
"docker-run": "docker compose up",
|
|
10
|
+
"generate-types": "tsc",
|
|
11
|
+
"pretest-ci": "npm run generate-types",
|
|
12
|
+
"pretest": "npm run generate-types",
|
|
13
|
+
"prepack": "npm run generate-types",
|
|
14
|
+
"prepare": "husky install"
|
|
15
|
+
},
|
|
16
|
+
"author": "Vladimir Adamic <vladimir.adamic@gmail.com>",
|
|
17
|
+
"repository": "github:Vunovati/otlp-logger",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@opentelemetry/api-logs": "^0.48.0",
|
|
21
|
+
"@opentelemetry/core": "^1.17.0",
|
|
22
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "^0.48.0",
|
|
23
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.48.0",
|
|
24
|
+
"@opentelemetry/exporter-logs-otlp-proto": "^0.48.0",
|
|
25
|
+
"@opentelemetry/resources": "^1.17.0",
|
|
26
|
+
"@opentelemetry/sdk-logs": "^0.48.0"
|
|
27
|
+
},
|
|
28
|
+
"types": "./types/otlp-logger.d.ts",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@commitlint/cli": "^18.2.0",
|
|
31
|
+
"@commitlint/config-conventional": "^18.1.0",
|
|
32
|
+
"@opentelemetry/api": "^1.4.1",
|
|
33
|
+
"@opentelemetry/instrumentation-http": "^0.48.0",
|
|
34
|
+
"@opentelemetry/sdk-node": "^0.48.0",
|
|
35
|
+
"@tapjs/sinon": "^1.1.16",
|
|
36
|
+
"@types/node": "^20.8.2",
|
|
37
|
+
"husky": "^9.0.10",
|
|
38
|
+
"require-inject": "^1.4.4",
|
|
39
|
+
"snazzy": "^9.0.0",
|
|
40
|
+
"standard": "^17.1.0",
|
|
41
|
+
"tap": "^18.5.8",
|
|
42
|
+
"tar-stream": "^3.1.6",
|
|
43
|
+
"testcontainers": "^10.2.1",
|
|
44
|
+
"tsd": "^0.30.3",
|
|
45
|
+
"typescript": "^5.2.2"
|
|
46
|
+
},
|
|
47
|
+
"standard": {
|
|
48
|
+
"ignore": [
|
|
49
|
+
"node_modules/"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"tsd": {
|
|
53
|
+
"directory": "./test/types"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"types",
|
|
57
|
+
"*.js"
|
|
58
|
+
],
|
|
59
|
+
"tap": {
|
|
60
|
+
"plugin": [
|
|
61
|
+
"@tapjs/sinon"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type RecordProcessorType = "batch" | "simple";
|
|
2
|
+
export type LogRecordProcessorOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* = "batch"
|
|
5
|
+
*/
|
|
6
|
+
recordProcessorType: RecordProcessorType;
|
|
7
|
+
exporterOptions?: ExporterOptions;
|
|
8
|
+
processorConfig?: import('@opentelemetry/sdk-logs').BufferConfig;
|
|
9
|
+
};
|
|
10
|
+
export type GrpcExporterOptions = {
|
|
11
|
+
protocol: "grpc";
|
|
12
|
+
grpcExporterOptions?: import('@opentelemetry/otlp-grpc-exporter-base').OTLPGRPCExporterConfigNode;
|
|
13
|
+
};
|
|
14
|
+
export type HttpExporterOptions = {
|
|
15
|
+
protocol: "http";
|
|
16
|
+
httpExporterOptions?: import('@opentelemetry/otlp-exporter-base').OTLPExporterNodeConfigBase;
|
|
17
|
+
};
|
|
18
|
+
export type ProtobufExporterOptions = {
|
|
19
|
+
protocol: "http/protobuf";
|
|
20
|
+
protobufExporterOptions?: import('@opentelemetry/otlp-exporter-base').OTLPExporterNodeConfigBase;
|
|
21
|
+
};
|
|
22
|
+
export type ConsoleExporterOptions = {
|
|
23
|
+
protocol: "console";
|
|
24
|
+
};
|
|
25
|
+
export type ExporterOptions = GrpcExporterOptions | HttpExporterOptions | ProtobufExporterOptions | ConsoleExporterOptions;
|
|
26
|
+
/**
|
|
27
|
+
* @param {LogRecordProcessorOptions | LogRecordProcessorOptions[]} [logRecordProcessorOptions]
|
|
28
|
+
*/
|
|
29
|
+
export function createLogProcessor(logRecordProcessorOptions?: LogRecordProcessorOptions | LogRecordProcessorOptions[]): import("@opentelemetry/sdk-logs").LogRecordProcessor;
|
|
30
|
+
//# sourceMappingURL=create-log-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-log-processor.d.ts","sourceRoot":"","sources":["../lib/create-log-processor.js"],"names":[],"mappings":"kCAsBa,OAAO,GAAG,QAAQ;;;;;yBAEjB,mBAAmB;sBACnB,eAAe;sBACf,OAAO,yBAAyB,EAAE,YAAY;;;cAiB9C,MAAM;0BACN,OAAO,wCAAwC,EAAE,0BAA0B;;;cAG3E,MAAM;0BACN,OAAO,mCAAmC,EAAE,0BAA0B;;;cAGtE,eAAe;8BACf,OAAO,mCAAmC,EAAE,0BAA0B;;;cAGtE,SAAS;;8BAEV,mBAAmB,GAAG,mBAAmB,GAAG,uBAAuB,GAAG,sBAAsB;AA/CzG;;GAEG;AACH,+DAFW,yBAAyB,GAAG,yBAAyB,EAAE,wDAQjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Using the MultiLogRecordProcessor from the sdk-logs package is currently not possible because it is not exported.
|
|
3
|
+
* This should work as a drop-in replacement.
|
|
4
|
+
*/
|
|
5
|
+
export class MultiLogRecordProcessor {
|
|
6
|
+
constructor(processors: any, forceFlushTimeoutMillis: any);
|
|
7
|
+
processors: any;
|
|
8
|
+
forceFlushTimeoutMillis: any;
|
|
9
|
+
forceFlush(): Promise<void>;
|
|
10
|
+
onEmit(logRecord: any): void;
|
|
11
|
+
shutdown(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=multi-log-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-log-processor.d.ts","sourceRoot":"","sources":["../lib/multi-log-processor.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IACE,2DAGC;IAFC,gBAA4B;IAC5B,6BAAsD;IAGxD,4BAUC;IAED,6BAEC;IAED,0BAEC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Options = {
|
|
2
|
+
loggerName: string;
|
|
3
|
+
serviceVersion: string;
|
|
4
|
+
logRecordProcessorOptions?: import('./create-log-processor').LogRecordProcessorOptions | import('./create-log-processor').LogRecordProcessorOptions[];
|
|
5
|
+
resourceAttributes?: any;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} Options
|
|
9
|
+
* @property {string} loggerName
|
|
10
|
+
* @property {string} serviceVersion
|
|
11
|
+
* @property {import('./create-log-processor').LogRecordProcessorOptions | import('./create-log-processor').LogRecordProcessorOptions[]} [logRecordProcessorOptions]
|
|
12
|
+
* @property {Object} [resourceAttributes={}]
|
|
13
|
+
*
|
|
14
|
+
* @param {Options} opts
|
|
15
|
+
*/
|
|
16
|
+
export function getOtlpLogger(opts: Options): {
|
|
17
|
+
/**
|
|
18
|
+
* @param {import('@opentelemetry/api-logs').LogRecord} obj
|
|
19
|
+
*/
|
|
20
|
+
emit(obj: import('@opentelemetry/api-logs').LogRecord): void;
|
|
21
|
+
shutdown(): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=otlp-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-logger.d.ts","sourceRoot":"","sources":["../lib/otlp-logger.js"],"names":[],"mappings":";gBAiBc,MAAM;oBACN,MAAM;gCACN,OAAO,wBAAwB,EAAE,yBAAyB,GAAG,OAAO,wBAAwB,EAAE,yBAAyB,EAAE;;;AAJvI;;;;;;;;GAQG;AACH,oCAFW,OAAO;IA0Bd;;OAEG;cADQ,OAAO,yBAAyB,EAAE,SAAS;;EASzD"}
|