Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Conversation

Copy link
Contributor

Copilot AI commented Oct 14, 2025

✅ Resolved: Add support for OTEL_EXPORTER_OTLP_HEADERS (#6)

Issue #6 asked: "Is there something like OTEL_EXPORTER_OTLP_HEADER that i can use to send my auth headers to otel service?"

Answer: YES! The standard OTEL_EXPORTER_OTLP_HEADERS environment variable is already fully supported by the OpenTelemetry PHP SDK. This PR adds comprehensive documentation to help users discover and use this feature.


Changes Made

All changes are documentation-only - the feature already works, we just needed to document it!

📄 Files Modified/Created:

  • README.md - Added authentication section with examples for Honeycomb, New Relic, Grafana Cloud
  • config/otel.php - Added detailed comments about all SDK environment variables
  • examples/middleware_example.php - Added authentication examples to basic and production configs
  • examples/authentication_example.php (NEW) - Comprehensive guide with 10 real-world examples + verification script
  • docs/AUTHENTICATION.md (NEW) - Dedicated authentication reference guide

📊 Statistics:

  • 464 lines of documentation added
  • 0 lines of code changed (feature already works!)
  • 5 files modified/created

How to Use (Solution to Issue #6)

Simply add the OTEL_EXPORTER_OTLP_HEADERS environment variable to your .env file:

# Simple API key
OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"

# Bearer token
OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer your-token"

# Multiple headers
OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"

Real-World Examples:

Honeycomb:

OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key"

New Relic:

OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net:4318
OTEL_EXPORTER_OTLP_HEADERS="api-key=your-license-key"

Testing

Users can verify their configuration:

php examples/authentication_example.php

With environment variables:

OTEL_EXPORTER_OTLP_HEADERS="x-api-key=test" php examples/authentication_example.php

Key Benefits

✅ No code changes required - standard OpenTelemetry SDK feature
✅ Works with all authentication methods (API keys, bearer tokens, basic auth)
✅ Supports multiple headers with comma-separated format
✅ Compatible with all major observability platforms
✅ Comprehensive documentation and examples provided
✅ Includes verification script for testing

This PR makes it easy for users to authenticate with their OTLP collectors and observability platforms.

Original prompt

尝试解决 @overtrue/laravel-open-telemetry/issues/6


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@overtrue overtrue marked this pull request as ready for review October 14, 2025 20:14
@overtrue overtrue closed this Oct 14, 2025
Copilot AI requested a review from overtrue October 14, 2025 20:17
Copilot finished work on behalf of overtrue October 14, 2025 20:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants