docs: improve gRPC insecure connection guidance#6215
Conversation
- Clarify that secure (TLS) connection is used by default - Add example showing http:// scheme for insecure connections - Add example with explicit insecure credentials configuration - Update documentation to better guide local development setup
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6215 +/- ##
==========================================
+ Coverage 95.43% 95.57% +0.14%
==========================================
Files 317 368 +51
Lines 9521 11795 +2274
Branches 2197 2751 +554
==========================================
+ Hits 9086 11273 +2187
- Misses 435 522 +87 🚀 New features to boost your workflow:
|
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
| By default, the exporter creates a secure (TLS) connection. When connecting to a local development collector without TLS, you can use an insecure connection by specifying the `http://` scheme in the URL: | ||
|
|
||
| ```js | ||
| const { NodeTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-node'); | ||
| const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc'); | ||
|
|
||
| const collectorOptions = { | ||
| url: 'http://localhost:4317', // http:// creates an insecure connection | ||
| }; | ||
|
|
||
| const exporter = new OTLPTraceExporter(collectorOptions); | ||
| const provider = new NodeTracerProvider({ | ||
| spanProcessors: [new SimpleSpanProcessor(exporter)] | ||
| }); | ||
|
|
||
| provider.register(); | ||
| ``` | ||
|
|
||
| Alternatively, you can explicitly configure insecure credentials: | ||
|
|
||
| ```js | ||
| const grpc = require('@grpc/grpc-js'); | ||
|
|
||
| const { NodeTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-node'); | ||
| const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc'); | ||
|
|
||
| const collectorOptions = { | ||
| url: 'localhost:4317', | ||
| credentials: grpc.credentials.createInsecure(), | ||
| }; | ||
|
|
||
| const exporter = new OTLPTraceExporter(collectorOptions); | ||
| const provider = new NodeTracerProvider({ | ||
| spanProcessors: [new SimpleSpanProcessor(exporter)] | ||
| }); | ||
|
|
||
| provider.register(); | ||
| ``` | ||
|
|
||
| To use TLS in Node.js, provide `credentials` option like so: |
There was a problem hiding this comment.
hi @zxzinn - thanks for adding this, can you also add this to the metrics/logs grpc exporters? :)
There was a problem hiding this comment.
@pichlermarc
Sure! I'll ping you again once I complete it, because I've been busy recently, thank you!
- Fix BatchRecordProcessor to BatchLogRecordProcessor in logs exporter example - Add documentation for http:// scheme for insecure connections - Add examples using grpc.credentials.createInsecure() for both logs and metrics exporters
| const loggerExporter = new OTLPLogExporter(collectorOptions); | ||
| const loggerProvider = new LoggerProvider({ | ||
| processors: [new BatchRecordProcessor(loggerExporter)] | ||
| processors: [new BatchLogRecordProcessor(loggerExporter)] |
There was a problem hiding this comment.
The BatchRecordProcessor was undefined, BatchLogRecordProcessor is the right one.
|
@pichlermarc |
Which problem is this PR solving?
When connecting the gRPC exporter to a local OTLP collector (e.g., Phoenix, Jaeger) without TLS, developers encounter errors like:
The README states "By default, plaintext connection is used" (line 47), which is outdated since v0.29.0. The exporter now defaults to secure connections, but there's no clear guidance on using insecure connections for local development.
Short description of the changes
http://URL scheme (recommended, simpler)credentials.createInsecure()(alternative)Type of change
Checklist: