From 63669e9dccd49a4bdd069d1afb7a91a0de092adf Mon Sep 17 00:00:00 2001 From: Said Sef <6002187+saidsef@users.noreply.github.com> Date: Sat, 1 Jun 2024 19:52:46 +0100 Subject: [PATCH] chore: update docs (#147) Add application required vars --- README.md | 20 +++++++++++++++++--- libs/index.mjs | 2 +- package.json | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a1ad420..b61ed72 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,28 @@ npm install @saidsef/tracing-node --save ## Usage +You can set required params via env variables or function: + +Env vars: +``` +CONTAINER_NAME +NODE_ENV +HOSTNAME +SERVICE_NAME +NAME_SPACE +SERVICE_VERSION +ENDPOINT +``` + +Function args ``` const { setupTracing } = require('@saidsef/tracing-node'); -setupTracing('hostname', 'application_name', 'endpoint'); +setupTracing({hostname: 'hostname', serviceName: 'service_name', endpoint: 'endpoint'}); ``` ``` import { setupTracing } from '@saidsef/tracing-node'; -setupTracing('hostname', 'application_name', 'endpoint'); +setupTracing({hostname: 'hostname', serviceName: 'service_name', endpoint: 'endpoint'}); ``` ### Required Parameters are @@ -37,7 +51,7 @@ setupTracing('hostname', 'application_name', 'endpoint'); | Name | Type | Description| |----- | ---- | ------------- | | hostname | string | container / pod hostname | -| application_name | string | service / application name | +| service_name | string | service / application name | | endpoint | string | tracing endpoint i.e. `://:` | ## Source diff --git a/libs/index.mjs b/libs/index.mjs index 5d2b225..ec1b80b 100644 --- a/libs/index.mjs +++ b/libs/index.mjs @@ -66,7 +66,7 @@ export function setupTracing (options={}) { const provider = new NodeTracerProvider({ resource: new Resource({ - [SemanticResourceAttributes.CONTAINER_NAME]: containerName, + [SemanticResourceAttributes.CONTAINER_NAME]: containerName || serviceName, [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: deploymentEnvironment, [SemanticResourceAttributes.HOSTNAME]: hostname, [SemanticResourceAttributes.SERVICE_NAME]: serviceName, diff --git a/package.json b/package.json index 04f0ca3..6a91cd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@saidsef/tracing-node", - "version": "2.1.0", + "version": "2.1.1", "description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages", "main": "libs/index.mjs", "scripts": {