Ola Ahlman
02/08/2023, 12:49 AMimport { NodeSDK } from '@opentelemetry/sdk-node'
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import logger from 'src/lib/Logger'
export const init = (url: string) => {
const traceExporter = new OTLPTraceExporter({ url })
const sdk = new NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: process.env.SIGNOZ_SERVICE_NAME,
[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: process.env.NODE_ENV,
})
})
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
.then(() => <http://logger.info|logger.info>('Tracing initialized for ' + url))
.catch((error) => logger.error('Error initializing tracing: ' + url + ' : ' + JSON.stringify(error)))
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => <http://logger.info|logger.info>('Tracing terminated for ' + url))
.catch((error) => logger.error('Error terminating tracing: ' + url + ' : ' + JSON.stringify(error)))
.finally(() => process.exit(0))
})
}
nitya-signoz
02/08/2023, 4:11 AMOla Ahlman
02/08/2023, 7:35 AMOla Ahlman
02/08/2023, 7:51 AMreceivers:
filelog/containers:
include: [ "/var/lib/docker/volumes/*/_data/*.log" ]
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
timestamp:
parse_from: attributes.timestamp
layout: '%Y-%m-%d %H:%M:%S'
- type: move
from: attributes.message
to: body
- type: move
from: attributes.label
to: <http://attributes.app|attributes.app>
- type: remove
field: attributes.timestamp
processors:
batch:
send_batch_size: 10000
send_batch_max_size: 11000
timeout: 10s
exporters:
otlp/us0:
endpoint: <http://123.123.123.123:4317>
tls:
insecure: true
otlp/de0:
endpoint: <http://123.123.123.123:4317>
tls:
insecure: true
service:
pipelines:
logs:
receivers: [filelog/containers]
processors: [batch]
exporters: [ otlp/us0, otlp/de0 ]
nitya-signoz
02/08/2023, 10:14 AMOla Ahlman
02/08/2023, 10:19 AMnitya-signoz
02/08/2023, 10:22 AMreceivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
filelog/containers:
include: [ "/var/lib/docker/volumes/*/_data/*.log" ]
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
timestamp:
parse_from: attributes.timestamp
layout: '%Y-%m-%d %H:%M:%S'
- type: move
from: attributes.message
to: body
- type: move
from: attributes.label
to: <http://attributes.app|attributes.app>
- type: remove
field: attributes.timestamp
processors:
batch:
send_batch_size: 10000
send_batch_max_size: 11000
timeout: 10s
exporters:
otlp/us0:
endpoint: <http://123.123.123.123:4317>
tls:
insecure: true
otlp/de0:
endpoint: <http://123.123.123.123:4317>
tls:
insecure: true
service:
pipelines:
logs:
receivers: [filelog/containers]
processors: [batch]
exporters: [ otlp/us0, otlp/de0 ]
traces:
receivers: [otlp]
processors: [batch]
exporters: [ otlp/us0, otlp/de0 ]
Ola Ahlman
02/08/2023, 10:26 AM<http://123.123.123.123:4317>
?nitya-signoz
02/08/2023, 10:28 AMOla Ahlman
02/08/2023, 10:35 AMnitya-signoz
02/08/2023, 10:35 AM