-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(localenv): add trace collection (with Tempo) in local playground (…
…#2816) * feat: add telemetry stack to localenv under command * chore: remove tempo * chore(localenv): update prometheus scrape interval * chore: explicitly set otel collector endpoint * chore: change prometheus scrape interval to 15s * chore: update dashboard queries * chore: add readme * chore: set auto-refresh within grafana dashboard * chore: add psql command * feat(backend): add trace auto-instrumentation * feat(localenv): add tempo to telemetry stack * feat(localenv): add example panel of traces in the grafana dashboard * chore: format for example dashboard * chore: rearrange dashboard * chore(backend): add instrumentation only if enabled
- Loading branch information
Showing
12 changed files
with
683 additions
and
68 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
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,17 @@ | ||
server: | ||
http_listen_port: 3200 | ||
|
||
distributor: | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
endpoint: 0.0.0.0:8492 | ||
|
||
storage: | ||
trace: | ||
backend: local | ||
local: | ||
path: /var/tempo/blocks | ||
wal: | ||
path: /var/tempo/wal |
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,80 @@ | ||
import { Config } from '../config/app' | ||
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc' | ||
import { Resource } from '@opentelemetry/resources' | ||
import { | ||
MeterProvider, | ||
PeriodicExportingMetricReader | ||
} from '@opentelemetry/sdk-metrics' | ||
|
||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc' | ||
import { api } from '@opentelemetry/sdk-node' | ||
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg' | ||
import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql' | ||
|
||
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http' | ||
import { | ||
BatchSpanProcessor, | ||
NodeTracerProvider | ||
} from '@opentelemetry/sdk-trace-node' | ||
import { registerInstrumentations } from '@opentelemetry/instrumentation' | ||
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici' | ||
|
||
// debug logger: | ||
// diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG) | ||
|
||
const SERVICE_NAME = 'RAFIKI_NETWORK' | ||
const rafikiResource = new Resource({ | ||
'service.name': SERVICE_NAME, | ||
instance: Config.instanceName | ||
}) | ||
|
||
if (Config.enableTelemetry) { | ||
const meterReaders = [] | ||
|
||
for (const url of Config.openTelemetryCollectors) { | ||
const metricExporter = new PeriodicExportingMetricReader({ | ||
exporter: new OTLPMetricExporter({ | ||
url | ||
}), | ||
exportIntervalMillis: Config.openTelemetryExportInterval ?? 15000 | ||
}) | ||
|
||
meterReaders.push(metricExporter) | ||
} | ||
|
||
const meterProvider = new MeterProvider({ | ||
resource: rafikiResource, | ||
readers: meterReaders | ||
}) | ||
|
||
api.metrics.setGlobalMeterProvider(meterProvider) | ||
} | ||
|
||
if (Config.enableTelemetryTraces) { | ||
const tracerProvider = new NodeTracerProvider({ | ||
resource: rafikiResource | ||
}) | ||
|
||
for (const url of Config.openTelemetryTraceCollectorUrls) { | ||
const traceExporter = new OTLPTraceExporter({ | ||
url | ||
}) | ||
|
||
tracerProvider.addSpanProcessor(new BatchSpanProcessor(traceExporter)) | ||
} | ||
|
||
tracerProvider.register() | ||
|
||
registerInstrumentations({ | ||
instrumentations: [ | ||
new UndiciInstrumentation(), | ||
new HttpInstrumentation(), | ||
new PgInstrumentation(), | ||
new GraphQLInstrumentation({ | ||
mergeItems: true, | ||
ignoreTrivialResolveSpans: true, | ||
ignoreResolveSpans: true | ||
}) | ||
] | ||
}) | ||
} |
Oops, something went wrong.