oscope-dev / scope

Scoping user machines
https://oscope-dev.github.io/scope/
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Make OpenTelemetry protocol configurable #132

Closed noizwaves closed 4 months ago

noizwaves commented 4 months ago

At Gusto, our OpenTelemetry endpoint is accessible via http only. This PR makes the protocol configurable via the SCOPE_OTEL_PROTOCOL environment variable.

The change was mostly a noop, except the omission of the with_metadata call on the HttpExporterBuilder. It looks like with_metadata is only available on the gRPC builder.

❯ ./target/debug/scope --help
...
Options:
...
      --otel-collector <OTEL_COLLECTOR>
          When set metrics will be sent to an otel collector at the endpoint provided

          [env: SCOPE_OTEL_ENDPOINT=]

      --otel-protocol <OTEL_PROTOCOL>
          [env: SCOPE_OTEL_PROTOCOL=]
          [default: grpc]
          [possible values: http, grpc]
...

Testing

Correct protocol ``` ❯ SCOPE_OTEL_ENDPOINT=https://devotel.uw2.staging.zp-int.com SCOPE_OTEL_PROTOCOL=http ./target/debug/scope list Name Description Path Name Description - analyze Analyze for known errors - doctor Run checks that will "checkup" your machine - intercept External sub-command, run `scope intercept` for help - lint Validate inputs, providing recommendations about configuration - list List the found config files, and resources detected - report Generate a bug report based from a command that was ran - version Print version info and exit ```
Incorrect protocol ``` ❯ SCOPE_OTEL_ENDPOINT=https://devotel.uw2.staging.zp-int.com SCOPE_OTEL_PROTOCOL=grpc ./target/debug/scope list Name Description Path Name Description - analyze Analyze for known errors - doctor Run checks that will "checkup" your machine - intercept External sub-command, run `scope intercept` for help - lint Validate inputs, providing recommendations about configuration - list List the found config files, and resources detected - report Generate a bug report based from a command that was ran - version Print version info and exit OpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (Unknown error): , detailed error message: transport error ```