{"id":15137771,"url":"https://github.com/serkan-ozal/otel-cli","last_synced_at":"2025-10-23T13:30:50.837Z","repository":{"id":179883341,"uuid":"662588324","full_name":"serkan-ozal/otel-cli","owner":"serkan-ozal","description":"CLI to send traces to an external OpenTelemetry collector OTLP endpoint","archived":false,"fork":false,"pushed_at":"2023-09-17T19:56:32.000Z","size":131,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T18:48:19.747Z","etag":null,"topics":["cli","jeager","monitoring","observability","open-telemetry","open-telemetry-collector","opentelemetry","opentelemetry-collector","tracing","zipkin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serkan-ozal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-05T13:04:08.000Z","updated_at":"2024-03-11T16:11:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b1629bb-c732-4cbd-aa98-3b572ad97224","html_url":"https://github.com/serkan-ozal/otel-cli","commit_stats":null,"previous_names":["serkan-ozal/otel-cli"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkan-ozal%2Fotel-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkan-ozal%2Fotel-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkan-ozal%2Fotel-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkan-ozal%2Fotel-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serkan-ozal","download_url":"https://codeload.github.com/serkan-ozal/otel-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237834599,"owners_count":19373757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","jeager","monitoring","observability","open-telemetry","open-telemetry-collector","opentelemetry","opentelemetry-collector","tracing","zipkin"],"created_at":"2024-09-26T07:01:55.470Z","updated_at":"2025-10-23T13:30:50.327Z","avatar_url":"https://github.com/serkan-ozal.png","language":"TypeScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# OTEL (OpenTelemetry) CLI\n\n![Build Status](https://github.com/serkan-ozal/otel-cli/actions/workflows/build.yml/badge.svg)\n![NPM Version](https://badge.fury.io/js/otel-cli.svg)\n![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)\n\n`otel-cli`, an application written in Node.js, is a command-line utility designed to \nsend OpenTelemetry traces to an external OpenTelemetry collector OTLP endpoint. \n\nIts main use case is within shell scripts and other situations \nwhere trace sending is most efficiently achieved by running an additional program.\n\n## Prerequisites\n- Node.js 14+\n\n## Setup\n\n```\nnpm install -g otel-cli\n```\n\nAfter install, check whether it is installed successfully:\n```\notel-cli --version\n```\nBy this command, you should see the installed version number if everything is installed properly.\n\n## Configuration\n\n### Common\n\n| CLI Option                 | Environment Variable | Mandatory | Choices | Description                   |\n|----------------------------|----------------------|-----------|---------|-------------------------------|\n| - `--version` \u003cbr/\u003e - `-V` |                      | NO        |         | Output the CLI version number |\n| - `--help`  \u003cbr/\u003e - `-h`   |                      | NO        |         | Display help for commands     |\n\n### Commands\n- `otel-cli export          [options]`: Create the span by given options and exports the created span to the OTEL collector OTLP endpoint.\n- `otel-cli generate-id     [options]`: Generate id of the specified type (`trace` or `span`) and outputs the generated id.\n- `otel-cli start-server    [options]`: Starts OTEL CLI server to be able to export traces in background.\n- `otel-cli shutdown-server [options]`: Gracefully shutdowns OTEL CLI server by exporting buffered traces before terminate.\n- `otel-cli help            [command]`: Display help for the given command.        \n\n### `export` command\n\n| CLI Option                                                                                 | Environment Variable                                                                | Mandatory | Choices                                                                                    | Default Value | Description                                                                                                                                                                                                                                                                                             | Example                                                                                          |\n|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|-----------|--------------------------------------------------------------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| - `--verbose` \u003cbr/\u003e - `-v`                                                                 | `OTEL_CLI_VERBOSE=true`                                                             | NO        |                                                                                            | `false`       | Enable verbose mode                                                                                                                                                                                                                                                                                     | `--verbose`                                                                                      |\n| - `--endpoint \u003curl\u003e` \u003cbr/\u003e - `-e \u003curl\u003e`                                                    | `OTEL_EXPORTER_OTLP_ENDPOINT=\u003curl\u003e`                                                 | YES       |                                                                                            |               | OTEL Exporter OTLP endpoint                                                                                                                                                                                                                                                                             | `--endpoint https://collector.otel.io`                                                           | \n| - `--protocol \u003curl\u003e` \u003cbr/\u003e - `-p \u003curl\u003e`                                                    | `OTEL_EXPORTER_OTLP_PROTOCOL=\u003cprotocol\u003e`                                            | NO        | - `http/json` \u003cbr/\u003e - `grpc`                                                               | `http/json`   | OTEL Exporter OTLP protocol                                                                                                                                                                                                                                                                             | - `--protocol http/json` \u003cbr/\u003e - `--protocol grpc`                                               | \n| - `--headers \u003ckey1=value1\u003e \u003ckey2=value2\u003e ...` \u003cbr/\u003e - `-h \u003ckey1=value1\u003e \u003ckey2=value2\u003e ...` | `OTEL_EXPORTER_OTLP_HEADERS=key1=value1\u003e,\u003ckey2=value2\u003e`                             | NO        |                                                                                            |               | OTEL Exporter OTLP headers \u003cbr/\u003e - In CLI options, headers are specified as space (` `) seperated key-value pairs (`key1=value1 key2=value2 key3=value3`) \u003cbr/\u003e - In environment variable, headers are specified as comma (`,`) seperated key-value pairs (`key1=value1,key2=value2,key3=value3`) \u003cbr/\u003e | `--headers x-api-key=abcd-1234 x-project-id=efgh-5678`                                           | \n| - `--traceparent \u003cheader\u003e` \u003cbr/\u003e - `-tp \u003cheader\u003e`                                          | `TRACEPARENT=\u003cheader\u003e`                                                              | NO        |                                                                                            |               | Traceparent header in W3C trace context format                                                                                                                                                                                                                                                          | `--traceparent 00-84b54e9330faae5350f0dd8673c98146-279fa73bc935cc05-01`                          | \n| - `--traceparent-disable` \u003cbr/\u003e - `-tpd`                                                   | `OTEL_CLI_TRACEPARENT_DISABLE=true`                                                 | NO        |                                                                                            | `false`       | Disable traceparent header based W3C trace context propagation for the exported span                                                                                                                                                                                                                    | `--traceparent-disable`                                                                          |\n| - `--traceparent-print` \u003cbr/\u003e - `-tpp`                                                     | `OTEL_CLI_TRACEPARENT_PRINT=true`                                                   | NO        |                                                                                            | `false`       | Print traceparent header in W3C trace context format for the exported span (the exported span id will be injected as parent span id in the header)                                                                                                                                                      | `--traceparent-print`                                                                            |\n| - `--trace-id \u003cid\u003e` \u003cbr/\u003e - `-t \u003cid\u003e`                                                      | `OTEL_CLI_TRACE_ID=\u003cid\u003e`                                                            | NO        |                                                                                            |               | Trace id                                                                                                                                                                                                                                                                                                | `--trace-id 84b54e9330faae5350f0dd8673c98146`                                                    | \n| - `--span-id \u003cid\u003e` \u003cbr/\u003e - `-s \u003cid\u003e`                                                       |                                                                                     | NO        |                                                                                            |               | Span id                                                                                                                                                                                                                                                                                                 | `--span-id b2746bb26cd13726`                                                                     | \n| - `--parent-span-id \u003cid\u003e` \u003cbr/\u003e - `-p \u003cid\u003e`                                                |                                                                                     | NO        |                                                                                            |               | Parent span id                                                                                                                                                                                                                                                                                          | `--parent-span-id 279fa73bc935cc05`                                                              | \n| - `--name \u003cname\u003e` \u003cbr/\u003e - `-s \u003cname\u003e`                                                      |                                                                                     | YES       |                                                                                            |               | Span name                                                                                                                                                                                                                                                                                               | `--name doPayment`                                                                               | \n| - `--service-name \u003cname\u003e` \u003cbr/\u003e - `-sn \u003cname\u003e`                                             | - `OTEL_CLI_SERVICE_NAME=\u003cservice-name\u003e` \u003cbr/\u003e - `OTEL_SERVICE_NAME=\u003cservice-name\u003e` | YES       |                                                                                            |               | Service name                                                                                                                                                                                                                                                                                            | `--service-name payment-service`                                                                 |\n| - `--kind \u003ckind\u003e` \u003cbr/\u003e - `-k \u003ckind\u003e`                                                      |                                                                                     | NO        | - `INTERNAL` \u003cbr/\u003e - `SERVER` \u003cbr/\u003e - `CLIENT` \u003cbr/\u003e - `PRODUCER` \u003cbr/\u003e - `CONSUMER` \u003cbr/\u003e | `INTERNAL`    | Span kind                                                                                                                                                                                                                                                                                               | - `--kind CLIENT` \u003cbr/\u003e - `--kind PRODUCER` \u003cbr/\u003e - ... \u003cbr/\u003e                                    | \n| - `--start-time-nanos \u003cnanos\u003e`                                                             |                                                                                     | NO        |                                                                                            |               | Start time in nanoseconds                                                                                                                                                                                                                                                                               | `--start-time-nanos 1688811191123456789`                                                         | \n| - `--start-time-micros \u003cmicros\u003e`                                                           |                                                                                     | NO        |                                                                                            |               | Start time in microseconds                                                                                                                                                                                                                                                                              | `--start-time-micros 1688811191123456`                                                           | \n| - `--start-time-millis \u003cmillis\u003e`                                                           |                                                                                     | NO        |                                                                                            |               | Start time in milliseconds                                                                                                                                                                                                                                                                              | `--start-time-millis 1688811191123`                                                              | \n| - `--start-time-secs \u003csecs\u003e`                                                               |                                                                                     | NO        |                                                                                            |               | Start time in seconds                                                                                                                                                                                                                                                                                   | `--start-time-secs 1688811191`                                                                   | \n| - `--end-time-nanos \u003cnanos\u003e`                                                               |                                                                                     | NO        |                                                                                            |               | End time in nanoseconds                                                                                                                                                                                                                                                                                 | `--end-time-nanos 1688811192123456789`                                                           | \n| - `--end-time-micros \u003cmicros\u003e`                                                             |                                                                                     | NO        |                                                                                            |               | End time in microseconds                                                                                                                                                                                                                                                                                | `--end-time-micros 1688811192123456`                                                             | \n| - `--end-time-millis \u003cmillis\u003e`                                                             |                                                                                     | NO        |                                                                                            |               | End time in milliseconds                                                                                                                                                                                                                                                                                | `--end-time-millis 1688811192123`                                                                | \n| - `--end-time-secs \u003csecs\u003e`                                                                 |                                                                                     | NO        |                                                                                            |               | End time in seconds                                                                                                                                                                                                                                                                                     | `--start-time-secs 1688811192`                                                                   | \n| - `--status-code \u003ccode\u003e` \u003cbr/\u003e - `-sc \u003ccode\u003e`                                              |                                                                                     | NO        | - `UNSET` \u003cbr/\u003e - `OK` \u003cbr/\u003e - `ERROR`  \u003cbr/\u003e                                              | `UNSET`       | Status code                                                                                                                                                                                                                                                                                             | - `--status-code OK` \u003cbr/\u003e - `--status-code ERROR` \u003cbr/\u003e - ... \u003cbr/\u003e                             | \n| - `--status-message \u003cmessage\u003e` \u003cbr/\u003e - `-sm \u003cmessage\u003e`                                     |                                                                                     | NO        |                                                                                            |               | Status message                                                                                                                                                                                                                                                                                          | `--status-message \"Invalid argument\"`                                                            | \n| - `--attributes \u003ckey-value-pairs...\u003e` \u003cbr/\u003e - `-a \u003ckey-value-pairs...\u003e`                    |                                                                                     | NO        |                                                                                            |               | Span attributes as space (` `) seperated key-value pairs (`key1=value1 key2=value2 key3=value3`)                                                                                                                                                                                                        | `--attributes key1=value1 key2=\\\"my value\\\" key3=true key4=123 key5=67.89 key6=\\\"456\\\"`          | \n| - `--resource-attributes \u003ckey-value-pairs...\u003e` \u003cbr/\u003e - `-ra \u003ckey-value-pairs...\u003e`          |                                                                                     | NO        |                                                                                            |               | Resource attributes as space (` `) seperated key-value pairs (`key1=value1 key2=value2 key3=value3`)                                                                                                                                                                                                    | `--resource-attributes key1=value1 key2=\\\"my value\\\" key3=true key4=123 key5=67.89 key6=\\\"456\\\"` |\n| - `--server-port` \u003cbr/\u003e - `-sp \u003cport\u003e`                                                     | `OTEL_CLI_SERVER_PORT=\u003cport\u003e`                                                       | NO        |                                                                                            | `7777`        | OTEL CLI server port for communicating over to export traces asynchronously in background                                                                                                                                                                                                               | - `--server-port 12345` \u003cbr/\u003e - `-sp 12345`                                                      | \n\n#### How OTEL Exporter OTLP HTTP traces endpoint resolved?\n- if `--endpoint` (or `-e`) option is specified,\n  OTLP HTTP traces endpoint is generated from the option value by appending `/v1/traces` to the end of the value.\n- Else, if `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable is specified,\n  OTLP HTTP traces endpoint is generated from the environment variable value by appending `/v1/traces` to the end of the value.\n- Else, CLI fails with the error.\n\n#### How trace id is resolved?\n- If `--trace-id` (or `-t`) option is specified,\n  trace id is used from the option value.\n- Else, if `OTEL_CLI_TRACE_ID` environment variable is specified,\n  trace id is used from the environment variable value.\n- Else, if `--traceparent` option (or `-tp`) is specified,\n  trace id is extracted from the traceparent header option value.\n- Else, if `TRACEPARENT` environment variable is specified,\n  trace id is extracted from the traceparent header environment variable value.\n- Else, CLI fails with the error (`Trace id is not specified`).\n\n#### How span id is resolved?\n- If `--span-id` (or `-s`) option is specified,\n  span id is used from the option value.\n- Else, random span id (16-hex-character lowercase string) is generated.\n\n#### How parent span id resolved?\n- If `--parent-span-id` (or `-p`) option is specified,\n  parent span id is used from the option value.\n- Else, if `OTEL_CLI_PARENT_SPAN_ID` environment variable is specified,\n  parent span id is used from the environment variable value.\n- Else, if `--traceparent` option (or `-tp`) is specified,\n  parent span id is extracted from the traceparent header option value.\n- Else, if `TRACEPARENT` environment variable is specified,\n  parent span id is extracted from the traceparent header environment variable value.\n- Else, it is assumed that there is no associated parent span.\n\n#### How start time is resolved?\n- If `--start-time-nanos` option is specified,\n  start time is used from the option value.\n- Else, if `--start-time-micros` option is specified,\n  start time is calculated by multiplying the option value by `1000` (to convert microseconds to nanoseconds).\n- Else, if `--start-time-millis` option is specified,\n  start time is calculated by multiplying the option value by `1000000` (to convert milliseconds to nanoseconds).\n- Else, if `--start-time-secs` option is specified,\n  start time is calculated by multiplying the option value by `1000000000` (to convert seconds to nanoseconds).\n- Else, CLI fails with the error (`Span start time must be specified in one of the supported formats (nanoseconds, microseconds, milliseconds, or seconds)!`).\n\n#### How end time is resolved?\n- If `--end-time-nanos` option is specified,\n  end time is used from the option value.\n- Else, if `--end-time-micros` option is specified,\n  end time is calculated by multiplying the option value by `1000` (to convert microseconds to nanoseconds).\n- Else, if `--end-time-millis` option is specified,\n  end time is calculated by multiplying the option value by `1000000` (to convert milliseconds to nanoseconds).\n- Else, if `--end-time-secs` option is specified,\n  end time is calculated by multiplying the option value by `1000000000` (to convert seconds to nanoseconds).\n- Else, CLI fails with the error (`Span end time must be specified in one of the supported formats (nanoseconds, microseconds, milliseconds, or seconds)!`).\n\n#### How to export traces asynchronously in background?\nBy default, `export` command sends traces synchronously to the configured OTLP endpoint by blocking the caller in the script.\nBut OTEL CLI also supports sending traces asynchronously through OTEL CLI server by exporting traces to the OTEL CLI server first over the specified HTTP port.\nThen OTEL CLI server buffers the received traces and sends them to the target OTLP endpoint asynchronously in background.\n\n##### Start OTEL CLI server\nTo be able to start OTEL CLI server, you can use `start-server` [command](#start-server-command).\nBy default, `start-server` command is blocking, so you should run it in the background yourself to not to block your program/script.\n\nFor example, in the Linux and MacOS environments, you can use `\u0026` operation after the command to run it in the background:\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH-HEADER-NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH-TOKEN\u003e\n# OTEL CLI server port is \"7777\" by default\nexport OTEL_CLI_SERVER_PORT=12345\n\n# \"start-server\" command is blocking for the caller.\n# So we put \"\u0026\" at the end of command to run OTEL CLI server in background without blocking here.\notel-cli start-server \u0026\n```\n\nor by specifying configurations through the options:\n```bash\n# \"start-server\" command is blocking for the caller.\n# So we put \"\u0026\" at the end of command to run OTEL CLI server in background without blocking here.\notel-cli start-server \\\n  --endpoint \u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e \\\n  --headers \u003cYOUR-OTEL-VENDOR-API-AUTH-HEADER-NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH-TOKEN\u003e \\\n  --server-port 12345 \\\n  \u0026\n```\n\n##### Shutdown OTEL CLI server\nSince the OTEL CLI server buffers the received traces to be send them asynchronously, \nit should be shutdown gracefully to flush the buffered traces by exporting them to the configured OTLP endpoint before terminated.\nOtherwise, some of the traces might be lost.\n\nTo be able to shutdown OTEL CLI server gracefully, you can use `shutdown-server` [command](#shutdown-server-command)\nby specifying the **same** port number you use while starting server.\n\n```bash\n# OTEL CLI server port is \"7777\" by default\nexport OTEL_CLI_SERVER_PORT=12345\n\notel-cli shutdown-server\n```\n\nor by specifying configurations through the options:\n```bash\notel-cli shutdown-server --server-port 12345\n```\n\n\u003e :warning:\nEven you don't shutdown the server manually by yourself, \nOTEL CLI server shutdown itself automatically when the parent process (program or script) exits.\nBut in any way, it is good practice to shutdown by yourself explicitly.\n\n### `generate-id` command\n\n| CLI Option                                  | Environment Variable    | Mandatory | Choices                 | Default Value | Description                    | Example                                |\n|---------------------------------------------|-------------------------|-----------|-------------------------|---------------|--------------------------------|----------------------------------------|\n| - `--verbose` \u003cbr/\u003e - `-v`                  | `OTEL_CLI_VERBOSE=true` | NO        |                         | `false`       | Enables verbose mode           | `--verbose`                            |\n| - `--type \u003cid-type\u003e` \u003cbr/\u003e - `-t \u003cid-type\u003e` |                         | YES       | - `trace` \u003cbr\u003e - `span` |               | Type of the id to be generated | - `--type trace` \u003cbr/\u003e - `--type span` | \n\n### `start-server` command\n\n| CLI Option                                                                                 | Environment Variable                                                                | Mandatory | Choices                      | Default Value | Description                                                                                                                                                                                                                                                                                             | Example                                                 |\n|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|-----------|------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|\n| - `--verbose` \u003cbr/\u003e - `-v`                                                                 | `OTEL_CLI_VERBOSE=true`                                                             | NO        |                              | `false`       | Enable verbose mode                                                                                                                                                                                                                                                                                     | `--verbose`                                             |\n| - `--endpoint \u003curl\u003e` \u003cbr/\u003e - `-e \u003curl\u003e`                                                    | `OTEL_EXPORTER_OTLP_ENDPOINT=\u003curl\u003e`                                                 | YES       |                              |               | OTEL Exporter OTLP endpoint                                                                                                                                                                                                                                                                             | `--endpoint https://collector.otel.io`                  | \n| - `--protocol \u003curl\u003e` \u003cbr/\u003e - `-p \u003curl\u003e`                                                    | `OTEL_EXPORTER_OTLP_PROTOCOL=\u003cprotocol\u003e`                                            | NO        | - `http/json` \u003cbr/\u003e - `grpc` | `http/json`   | OTEL Exporter OTLP protocol                                                                                                                                                                                                                                                                             | - `--protocol http/json` \u003cbr/\u003e - `--protocol grpc`      | \n| - `--headers \u003ckey1=value1\u003e \u003ckey2=value2\u003e ...` \u003cbr/\u003e - `-h \u003ckey1=value1\u003e \u003ckey2=value2\u003e ...` | `OTEL_EXPORTER_OTLP_HEADERS=key1=value1\u003e,\u003ckey2=value2\u003e`                             | NO        |                              |               | OTEL Exporter OTLP headers \u003cbr/\u003e - In CLI options, headers are specified as space (` `) seperated key-value pairs (`key1=value1 key2=value2 key3=value3`) \u003cbr/\u003e - In environment variable, headers are specified as comma (`,`) seperated key-value pairs (`key1=value1,key2=value2,key3=value3`) \u003cbr/\u003e | `--headers x-api-key=abcd-1234 x-project-id=efgh-5678`  | \n| - `--server-port` \u003cbr/\u003e - `-sp \u003cport\u003e`                                                     | `OTEL_CLI_SERVER_PORT=\u003cport\u003e`                                                       | NO        |                              | `7777`        | OTEL CLI server port to start on                                                                                                                                                                                                                                                                        | - `--server-port 12345` \u003cbr/\u003e - `-sp 12345`             | \n\n### `shutdown-server` command\n\n| CLI Option                                                                                 | Environment Variable                                                                | Mandatory | Choices                                                                                    | Default Value | Description                                                        | Example                                                                                 |\n|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|-----------|--------------------------------------------------------------------------------------------|---------------|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------|\n| - `--verbose` \u003cbr/\u003e - `-v`                                                                 | `OTEL_CLI_VERBOSE=true`                                                             | NO        |                                                                                            | `false`       | Enable verbose mode                                                | `--verbose`                                                                             |\n| - `--server-port` \u003cbr/\u003e - `-sp \u003cport\u003e`                                                     | `OTEL_CLI_SERVER_PORT=\u003cport\u003e`                                                       | NO        |                                                                                            | `7777`        | OTEL CLI server port for communicating over to shutdown gracefully | - `--server-port 12345` \u003cbr/\u003e - `-sp 12345`                                             | \n\n## Examples\n\n#### Export trace [Linux]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH-HEADER-NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH-TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# 1. Build auth service\n########################################\n\n# Get start time of auth service project build process in nanoseconds\nstart_time=$(date +%s%9N)\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in nanoseconds\nend_time=$(date +%s%9N)\n\n# Export span of the auth service build process\notel-cli export \\\n  --name build-auth-service --start-time-nanos ${start_time} --end-time-nanos ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java\n\n########################################\n\n# 2. Build payment service\n########################################\n\n# Get start time of payment service project build process in nanoseconds\nstart_time=$(date +%s%9N)\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in nanoseconds\nend_time=$(date +%s%9N)\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --start-time-nanos ${start_time} --end-time-nanos ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n\n########################################  \n```\n\n#### Export trace [MacOS]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH_HEADER_NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH_TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# 1. Build auth service\n########################################\n\n# Get start time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time=$(node -e 'console.log(Date.now())')\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time=$(node -e 'console.log(Date.now())')\n\n# Export span of the auth service build process\notel-cli export \\\n  --name build-auth-service --start-time-millis ${start_time} --end-time-millis ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java\n\n########################################\n\n# 1. Build payment service\n########################################\n\n# Get start time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time=$(node -e 'console.log(Date.now())')\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time=$(node -e 'console.log(Date.now())')\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --start-time-millis ${start_time} --end-time-millis ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n\n########################################\n\n```\n\n#### Export trace (Parent-Child) [Linux]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH_HEADER_NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH_TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# 1. Build services\n################################################################################\n\nroot_span_id=$(otel-cli generate-id -t span)\n\n# Get start time of whole build process in nanoseconds\nstart_time0=$(date +%s%9N)\n\n# 1.1. Build auth service\n########################################\n\n# Get start time of auth service project build process in nanoseconds\nstart_time1=$(date +%s%9N)\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in nanoseconds\nend_time1=$(date +%s%9N)\n\n# Export span of the auth service project build process\notel-cli export \\\n  --name build-auth-service --parent-span-id ${root_span_id} --start-time-nanos ${start_time1} --end-time-nanos ${end_time1} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java  \n\n########################################\n\n# 1.2. Build payment service\n########################################\n\n# Get start time of payment service project build process in nanoseconds\nstart_time2=$(date +%s%9N)\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in nanoseconds\nend_time2=$(date +%s%9N)\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --parent-span-id ${root_span_id} --start-time-millis ${start_time2} --end-time-millis ${end_time2} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n  \n########################################\n\n# Get end time of whole build process in nanoseconds\nend_time0=$(date +%s%9N)\n\n# Export span of the whole build process\notel-cli export \\\n  --name build-services --span-id ${root_span_id} --start-time-millis ${start_time0} --end-time-millis ${end_time0} \\\n  --kind INTERNAL --status-code OK\n\n################################################################################\n```\n\n#### Export trace (Parent-Child) [MacOS]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH_HEADER_NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH_TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# 1. Build services\n################################################################################\n\nroot_span_id=$(otel-cli generate-id -t span)\n\n# Get start time of whole build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time0=$(node -e 'console.log(Date.now())')\n\n# 1.1. Build auth service\n########################################\n\n# Get start time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time1=$(node -e 'console.log(Date.now())')\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time1=$(node -e 'console.log(Date.now())')\n\n# Export span of the auth service project build process\notel-cli export \\\n  --name build-auth-service --parent-span-id ${root_span_id} --start-time-millis ${start_time1} --end-time-millis ${end_time1} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java  \n\n########################################\n\n# 1.2. Build payment service\n########################################\n\n# Get start time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time2=$(node -e 'console.log(Date.now())')\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time2=$(node -e 'console.log(Date.now())')\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --parent-span-id ${root_span_id} --start-time-millis ${start_time2} --end-time-millis ${end_time2} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n  \n########################################\n\n# Get end time of whole build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time0=$(node -e 'console.log(Date.now())')\n\n# Export span of the whole build process\notel-cli export \\\n  --name build-services --span-id ${root_span_id} --start-time-millis ${start_time0} --end-time-millis ${end_time0} \\\n  --kind INTERNAL --status-code OK\n\n################################################################################\n```\n\n#### Export trace asynchronously in background [Linux]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH-HEADER-NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH-TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\n# Specify port number to start server port on (the default value is \"7777\") \n# to be used by \"otel-cli server-start\" command.\n# Additionally, this environment variable will also be picked up by \"otel-cli export\" command automatically \n# while exporting traces to send asynchronously over OTEL CLI server.\nexport OTEL_CLI_SERVER_PORT=12345\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# \"start-server\" command is blocking for the caller.\n# So we put \"\u0026\" at the end of command to run OTEL CLI server in background without blocking here.\notel-cli start-server \u0026\n\nfunction shutdown_server {\n  # Shutdown OTEL CLI server.\n  # \n  # Note: \n  #     Even we don't shutdown manually, OTEL CLI server shutdown itself automatically \n  #     when this bash process (its parent process) exits.\n  #     But in any way, it is good practice to shutdown by ourself explicitly.\n  otel-cli shutdown-server\n}\ntrap shutdown_server EXIT\n\n# 1. Build auth service\n########################################\n\n# Get start time of auth service project build process in nanoseconds\nstart_time=$(date +%s%9N)\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in nanoseconds\nend_time=$(date +%s%9N)\n\n# Export span of the auth service build process\notel-cli export \\\n  --name build-auth-service --start-time-nanos ${start_time} --end-time-nanos ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java\n\n########################################\n\n# 2. Build payment service\n########################################\n\n# Get start time of payment service project build process in nanoseconds\nstart_time=$(date +%s%9N)\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in nanoseconds\nend_time=$(date +%s%9N)\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --start-time-nanos ${start_time} --end-time-nanos ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n\n########################################  \n```\n\n#### Export trace asynchronously in background [MacOS]\n```bash\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\u003cYOUR-OTEL-VENDOR-OTLP-ENDPOINT\u003e\nexport OTEL_EXPORTER_OTLP_HEADERS=\u003cYOUR-OTEL-VENDOR-API-AUTH-HEADER-NAME\u003e=\u003cYOUR-OTEL-VENDOR-API-AUTH-TOKEN\u003e\nexport OTEL_SERVICE_NAME=build\n# Specify port number to start server port on (the default value is \"7777\") \n# to be used by \"otel-cli server-start\" command.\n# Additionally, this environment variable will also be picked up by \"otel-cli export\" command automatically \n# while exporting traces to send asynchronously over OTEL CLI server.\nexport OTEL_CLI_SERVER_PORT=12345\nexport OTEL_CLI_TRACE_ID=$(otel-cli generate-id -t trace)\n\n# \"start-server\" command is blocking for the caller.\n# So we put \"\u0026\" at the end of command to run OTEL CLI server in background without blocking here.\notel-cli start-server \u0026\n\nfunction shutdown_server {\n  # Shutdown OTEL CLI server.\n  # \n  # Note: \n  #     Even we don't shutdown manually, OTEL CLI server shutdown itself automatically \n  #     when this bash process (its parent process) exits.\n  #     But in any way, it is good practice to shutdown by ourself explicitly.\n  otel-cli shutdown-server\n}\ntrap shutdown_server EXIT\n\n# 1. Build auth service\n########################################\n\n# Get start time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time=$(node -e 'console.log(Date.now())')\n\n# Build auth service project\npushd auth-service\nmvn clean package\npopd\n\n# Get end time of auth service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time=$(node -e 'console.log(Date.now())')\n\n# Export span of the auth service build process\notel-cli export \\\n  --name build-auth-service --start-time-millis ${start_time} --end-time-millis ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=auth-service buildTool=maven runtime=java\n\n########################################\n\n# 1. Build payment service\n########################################\n\n# Get start time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nstart_time=$(node -e 'console.log(Date.now())')\n\n# Build payment service project\npushd payment-service\nnpm run build\npopd\n\n# Get end time of payment service project build process in milliseconds (\"date\" command only support second resolution in MacOS)\nend_time=$(node -e 'console.log(Date.now())')\n\n# Export span of the payment service project build process\notel-cli export \\\n  --name build-payment-service --start-time-millis ${start_time} --end-time-millis ${end_time} \\\n  --kind INTERNAL --status-code OK --attributes serviceName=payment-service buildTool=npm runtime=node\n\n########################################\n```\n\n## Roadmap\n- Automated bash command tracing by wrapping command to be executed\n- `http/protobuf` support as OTLP protocol\n- `grpc` support as OTLP protocol\n- Batch transmission support while sending traces to OTLP endpoint to reduce network RTT (Round Trip Time)\n\n## Issues and Feedback\n\n[![Issues](https://img.shields.io/github/issues/serkan-ozal/otel-cli.svg)](https://github.com/serkan-ozal/otel-cli/issues?q=is%3Aopen+is%3Aissue)\n[![Closed issues](https://img.shields.io/github/issues-closed/serkan-ozal/otel-cli.svg)](https://github.com/serkan-ozal/otel-cli/issues?q=is%3Aissue+is%3Aclosed)\n\nPlease use [GitHub Issues](https://github.com/serkan-ozal/otel-cli/issues) for any bug report, feature request and support.\n\n## Contribution\n\n[![Pull requests](https://img.shields.io/github/issues-pr/serkan-ozal/otel-cli.svg)](https://github.com/serkan-ozal/otel-cli/pulls?q=is%3Aopen+is%3Apr)\n[![Closed pull requests](https://img.shields.io/github/issues-pr-closed/serkan-ozal/otel-cli.svg)](https://github.com/serkan-ozal/otel-cli/pulls?q=is%3Apr+is%3Aclosed)\n[![Contributors](https://img.shields.io/github/contributors/serkan-ozal/otel-cli.svg)]()\n\nIf you would like to contribute, please\n- Fork the repository on GitHub and clone your fork.\n- Create a branch for your changes and make your changes on it.\n- Send a pull request by explaining clearly what is your contribution.\n\n\u003e Tip:\n\u003e Please check the existing pull requests for similar contributions and\n\u003e consider submit an issue to discuss the proposed feature before writing code.\n\n## License\n\nLicensed under [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkan-ozal%2Fotel-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserkan-ozal%2Fotel-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkan-ozal%2Fotel-cli/lists"}