### Minimalistic Pino and OpenTelemetry Transport Setup Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=readme Demonstrates a basic setup for Pino logging with the OpenTelemetry transport. It initializes Pino with the transport and logs messages at intervals. This requires the 'pino' and 'pino-opentelemetry-transport' packages to be installed. ```javascript const pino = require('pino') const transport = pino.transport({ target: 'pino-opentelemetry-transport' }) const logger = pino(transport) transport.on('ready', () => { setInterval(() => { logger.info('test log') }, 1000) }) ``` -------------------------------- ### Install pino-opentelemetry-transport Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=dependencies Installs the pino-opentelemetry-transport package using npm. This is the primary step to integrate the transport into a Pino logging setup. ```bash npm i pino-opentelemetry-transport ``` -------------------------------- ### Run Example Service Locally Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=code Command to execute a specific example service (e.g., minimalistic) using Node.js. This is used for testing the transport integration. ```bash node examples/minimalistic/minimalistic.js ``` -------------------------------- ### Install Pino and Transport Locally Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=dependencies Installs both the Pino logger and the pino-opentelemetry-transport package into the project's dependencies. ```bash npm install pino pino-opentelemetry-transport ``` -------------------------------- ### Run Local Repository Test Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index Commands to test the pino-opentelemetry-transport repository locally. It includes running the OTLP collector in a Docker container, executing a minimalistic example, and tailing the log output file. ```bash npm run docker-run node examples/minimalistic/minimalistic.js tail -f /tmp/test-logs/otlp-logs.log ``` -------------------------------- ### Run Dockerized OTLP Collector Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=versions A convenience npm script to run the OpenTelemetry Collector in a Docker container, simplifying the setup for testing locally. ```bash npm run docker-run ``` -------------------------------- ### OpenTelemetry Collector Configuration Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=dependencies Provides a sample YAML configuration for an OpenTelemetry collector. This setup defines OTLP receivers for gRPC and HTTP, an exporter to a file, and a batch processor, enabling the collection and processing of logs. ```yaml receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 exporters: file: path: ./etc/test-logs/otlp-logs.log flush_interval: 1 debug: verbosity: basic processors: batch: service: pipelines: logs: receivers: [otlp] processors: [] exporters: [debug, file] ``` -------------------------------- ### Running OpenTelemetry Collector with Docker Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=dependencies Command to run the OpenTelemetry collector in a Docker container. It mounts the configuration file and a log directory, exposing the collector's ports and starting it with the specified configuration. ```bash docker run --volume=$(pwd)/otel-collector-config.yaml:/etc/otel-collector-config.yaml:rw --volume=/tmp/test-logs:/etc/test-logs:rw -p 4317:4317 -d otel/opentelemetry-collector-contrib:latest --config=/etc/otel-collector-config.yaml ``` -------------------------------- ### Minimalistic Pino with OpenTelemetry Transport Usage Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=dependencies Demonstrates a basic setup for using pino-opentelemetry-transport. It configures Pino to use the transport, sets up an interval to send logs, and specifies OpenTelemetry collector endpoint and resource attributes via environment variables. ```javascript const pino = require('pino') const transport = pino.transport({ target: 'pino-opentelemetry-transport' }) const logger = pino(transport) transport.on('ready', () => { setInterval(() => { logger.info('test log') }, 1000) }) ``` ```bash OTEL_EXPORTER_OTLP_LOGS_PROTOCOL='grpc' OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4317 OTEL_RESOURCE_ATTRIBUTES="service.name=my-service,service.version=1.2.3" node index.js ``` -------------------------------- ### Running Pino OpenTelemetry Transport with Environment Variables Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=readme Executes a Node.js script that uses Pino with the OpenTelemetry transport. It configures the OTLP logs protocol, endpoint, and resource attributes via environment variables. ```bash OTEL_EXPORTER_OTLP_LOGS_PROTOCOL='grpc' OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4317 OTEL_RESOURCE_ATTRIBUTES="service.name=my-service,service.version=1.2.3" node index.js ``` -------------------------------- ### Observe Log File Output Source: https://www.npmjs.com/package/pino-opentelemetry-transport/index_activetab=versions Command to tail the log file generated by the OpenTelemetry Collector. This allows for real-time observation of the logs being processed and exported. ```bash tail -f /tmp/test-logs/otlp-logs.log ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.