-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from Joystream/dev
Release: `v3.4.0`
- Loading branch information
Showing
29 changed files
with
1,749 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ error.log | |
Thumbs.db | ||
**/node_modules/ | ||
|
||
# Serverless | ||
.serverless | ||
.webpack | ||
# Env files | ||
.env | ||
!opentelemetry/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Required env variables for the Elasticsearch exporters | ||
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8200 | ||
OTEL_RESOURCE_ATTRIBUTES="service.name=youtube-synch-httpApi,deployment.environment=production" | ||
OTEL_METRICS_EXPORTER="otlp" | ||
|
||
# Optional env vars to configure the opentelemetry exporters | ||
OTEL_MAX_QUEUE_SIZE=8192 # 4 times of default queue size | ||
OTEL_MAX_EXPORT_BATCH_SIZE=1024 # 2 times of default batch size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api') | ||
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node') | ||
|
||
/** | ||
* Error: "@opentelemetry/instrumentation-grpc Module @grpc/grpc-js has | ||
* been loaded before @opentelemetry/instrumentation-grpc so it might not work, | ||
* please initialize it before requiring @grpc/grpc-js" | ||
* | ||
* Fix: "call getNodeAutoInstrumentations() before require('@opentelemetry/sdk-node');" | ||
*/ | ||
// | ||
|
||
// Disable DNS instrumentation, because the instrumentation does not correctly patches `dns.lookup` function | ||
// if the function is converted to a promise-based method using `utils.promisify(dns.lookup)` | ||
// See: https://github.com/Joystream/joystream/pull/4779#discussion_r1262515887 | ||
const instrumentations = getNodeAutoInstrumentations({ '@opentelemetry/instrumentation-dns': { enabled: false } }) | ||
|
||
const { NodeSDK } = require('@opentelemetry/sdk-node') | ||
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto') | ||
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-proto') | ||
const { PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics') | ||
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-node') | ||
|
||
const path = require('path') | ||
require('dotenv').config({ path: path.resolve(__dirname, `.env`) }) | ||
|
||
// For troubleshooting, set the log level to DiagLogLevel.DEBUG | ||
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO) | ||
|
||
function addInstrumentation() { | ||
const instrumentation = new NodeSDK({ | ||
spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter(), { | ||
maxQueueSize: parseInt(process.env.OTEL_MAX_QUEUE_SIZE || '8192'), | ||
maxExportBatchSize: parseInt(process.env.OTEL_MAX_EXPORT_BATCH_SIZE || '1024'), | ||
}), | ||
metricReader: new PeriodicExportingMetricReader({ | ||
exporter: new OTLPMetricExporter(), | ||
}), | ||
instrumentations, | ||
}) | ||
|
||
// Start Opentelemetry NodeJS Instrumentation | ||
diag.info('Starting tracing...') | ||
instrumentation.start() | ||
|
||
// gracefully shut down the SDK on process exit | ||
process.on('SIGTERM', () => { | ||
instrumentation | ||
.shutdown() | ||
.then(() => console.log('Tracing terminated')) | ||
.catch((error) => console.log('Error terminating tracing', error)) | ||
.finally(() => process.exit(0)) | ||
}) | ||
} | ||
|
||
addInstrumentation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ "$TELEMETRY_ENABLED" = "yes" ]]; then | ||
node --require ./opentelemetry/index.js ./bin/run start $* | ||
else | ||
echo "Starting YouTube Sync Service without telemetry..." | ||
./bin/run start $* | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.