diff --git a/.env b/.env index 3c894975c1..13e8c403b8 100644 --- a/.env +++ b/.env @@ -123,6 +123,12 @@ APP_PRIVATE_KEY=this-is-not-so-secret-change-it TRUSTED_REVERSE_PROXIES=1 # ===================================================================================== +## Telemetry +# yes/no +TELEMETRY_ENABLED=no +# TELEMETRY_ENDPOINT=http://apm-server:8200 +TELEMETRY_ENDPOINT=http://collector:4318 + # joystream/node docker image tag # We do not provide a default value - scripts that startup a joystream-node service # Should be explicit about what version to use. diff --git a/docker-compose.yml b/docker-compose.yml index c19833ae6f..9774b2674d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,11 +32,11 @@ services: environment: # ACCOUNT_URI overrides command line arg --accountUri - ACCOUNT_URI=${COLOSSUS_1_TRANSACTOR_URI} - # - OTEL_EXPORTER_OTLP_ENDPOINT=http://apm-server:8200 - # - OTEL_RESOURCE_ATTRIBUTES=service.name=colossus-1,deployment.environment=production - entrypoint: ['yarn'] + - OTEL_EXPORTER_OTLP_ENDPOINT=${TELEMETRY_ENDPOINT} + - OTEL_RESOURCE_ATTRIBUTES=service.name=colossus-1,deployment.environment=production + entrypoint: ['/joystream/entrypoints/storage.sh'] command: [ - 'start', '--worker=${COLOSSUS_1_WORKER_ID}', '--port=3333', '--uploads=/data', + 'server', '--worker=${COLOSSUS_1_WORKER_ID}', '--port=3333', '--uploads=/data', '--sync', '--syncInterval=1', '--queryNodeEndpoint=${COLOSSUS_QUERY_NODE_URL}', '--apiUrl=${JOYSTREAM_NODE_WS}', @@ -74,14 +74,14 @@ services: JOYSTREAM_DISTRIBUTOR__DIRECTORIES__ASSETS: /data JOYSTREAM_DISTRIBUTOR__DIRECTORIES__CACHE_STATE: /cache JOYSTREAM_DISTRIBUTOR__LOGS__FILE__PATH: /logs - # OTEL_EXPORTER_OTLP_ENDPOINT: http://apm-server:8200 - # OTEL_RESOURCE_ATTRIBUTES: service.name=distributor-1,deployment.environment=production + OTEL_EXPORTER_OTLP_ENDPOINT: ${TELEMETRY_ENDPOINT} + OTEL_RESOURCE_ATTRIBUTES: service.name=distributor-1,deployment.environment=production # JOYSTREAM_DISTRIBUTOR__LOGS__CONSOLE: "off" # JOYSTREAM_DISTRIBUTOR__LOGS__FILE: "off" # JOYSTREAM_DISTRIBUTOR__LOGS__ELASTIC: "{\"level\":\"debug\",\"endpoint\":\"http://elasticsearch:9200\"}" # JOYSTREAM_DISTRIBUTOR__LIMITS__STORAGE: 50G # JOYSTREAM_DISTRIBUTOR__BUCKETS: "[\"1:0\",\"1:1\"]" - entrypoint: ['yarn'] + entrypoint: ['/joystream/entrypoints/distributor.sh'] command: ['start'] colossus-2: @@ -200,8 +200,8 @@ services: - GRAPHQL_PLAYGROUND_ENDPOINT=${GRAPHQL_PLAYGROUND_ENDPOINT} - GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT=${GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT} - GRAPHQL_PLAYGROUND_CDN_URL=${GRAPHQL_PLAYGROUND_CDN_URL} - # - OTEL_EXPORTER_OTLP_ENDPOINT=http://apm-server:8200 - # - OTEL_RESOURCE_ATTRIBUTES=service.name=query-node,deployment.environment=production + - OTEL_EXPORTER_OTLP_ENDPOINT=${TELEMETRY_ENDPOINT} + - OTEL_RESOURCE_ATTRIBUTES=service.name=query-node,deployment.environment=production ports: - "${GRAPHQL_SERVER_PORT}:${GRAPHQL_SERVER_PORT}" - "127.0.0.1:${PROCESSOR_STATE_APP_PORT}:${PROCESSOR_STATE_APP_PORT}" @@ -212,7 +212,7 @@ services: source: . target: /joystream working_dir: /joystream - command: ['yarn', 'workspace', 'query-node-root', 'query-node:start:prod'] + entrypoint: ['/joystream/entrypoints/graphql-server.sh'] processor: image: node:14 diff --git a/entrypoints/distributor.sh b/entrypoints/distributor.sh new file mode 100755 index 0000000000..6f3be713f6 --- /dev/null +++ b/entrypoints/distributor.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# docker entrypoint fot distributor node, to allow running with telemetry +if [[ "$TELEMETRY_ENABLED" = "yes" ]] && [[ $1 = "start" ]]; then + node --require @joystream/opentelemetry /joystream/distributor-node/bin/run $* +else + /joystream/distributor-node/bin/run $* +fi diff --git a/entrypoints/graphql-server.sh b/entrypoints/graphql-server.sh new file mode 100755 index 0000000000..4faddd6f80 --- /dev/null +++ b/entrypoints/graphql-server.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# docker entrypoint fot graphql-server, to allow running with telemetry +if [[ "$TELEMETRY_ENABLED" = "yes" ]]; then + yarn workspace query-node-root query-node:start:prod:with-instrumentation $* +else + yarn workspace query-node-root query-node:start:prod $* +fi diff --git a/entrypoints/storage.sh b/entrypoints/storage.sh new file mode 100755 index 0000000000..96dc9660f9 --- /dev/null +++ b/entrypoints/storage.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# docker entrypoint fot storage node, to allow running with telemetry +if [[ "$TELEMETRY_ENABLED" = "yes" ]] && [[ $1 = "server" ]]; then + node --require @joystream/opentelemetry /joystream/storage-node/bin/run $* +else + /joystream/storage-node/bin/run $* +fi