Skip to main content

posthog-otel-exporter

Overview

posthog-otel-exporter is an OpenTelemetry SpanExporter for Python that sends trace events to PostHog. This allows you to analyze and visualize your application's traces and events in PostHog.

Installation

pip install posthog-otel-exporter

Configuration

You need a PostHog project API key and endpoint. These can be provided as arguments or via environment variables:

  • POSTHOG_API_KEY: Your PostHog project API key
  • POSTHOG_ENDPOINT: Your PostHog instance endpoint (e.g., https://app.posthog.com)

Usage with OpenTelemetry

Below is an example of how to use PosthogSpanExporter with OpenTelemetry's tracing SDK:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from posthog_otel_exporter.exporter import PosthogSpanExporter

# Set up the tracer provider
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)

# Configure the Posthog exporter (API key and endpoint can also be set via env vars)
exporter = PosthogSpanExporter(
    posthog_api_key="<your-posthog-api-key>",
    posthog_endpoint="<your-posthog-endpoint>"
)

# Add the exporter to the span processor
span_processor = BatchSpanProcessor(exporter)
trace.get_tracer_provider().add_span_processor(span_processor)

# Example span
with tracer.start_as_current_span("example-span") as span:
    span.add_event("event-name", {"key": "value"})

Environment Variables

Alternatively, set the following environment variables:

export POSTHOG_API_KEY="<your-posthog-api-key>"
export POSTHOG_ENDPOINT="<your-posthog-endpoint>"

Then initialize the exporter without arguments:

exporter = PosthogSpanExporter()

License and Contributions

This project is distributed under the MIT License.

Contributions are welcome and encouraged, and should follow the guidelines in CONTRIBUTING.md.

Metadata

Release files for posthog-otel-exporter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for posthog-otel-exporter 0.1.0
File Size Uploaded Provenance Actions
posthog_otel_exporter-0.1.0.tar.gz 38.1 kB Without provenance Details for posthog_otel_exporter-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for posthog-otel-exporter 0.1.0
File Interpreter ABI Platform Actions
posthog_otel_exporter-0.1.0-py3-none-any.whl Python 3 none any Details for posthog_otel_exporter-0.1.0-py3-none-any.whl

Total release size: 42.3 kB

Release files / posthog_otel_exporter-0.1.0.tar.gz

Download URL posthog_otel_exporter-0.1.0.tar.gz
Size 38.1 kB
Tags Source
SHA-256 checksum
How to use checksums
381d20925879cbc181ba113eab8a205e601383c2e9fc5189c8dbf6d914320992
BLAKE2b-256 checksum
How to use checksums
06567e6531921d101f2bc07d34feec0cc75492595a949f887a807ab3a19088df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / posthog_otel_exporter-0.1.0-py3-none-any.whl

Download URL posthog_otel_exporter-0.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82488426b013e5588ede908093bcbe7b2a862bdf5f7c9cc406e49c6584fc5f1e
BLAKE2b-256 checksum
How to use checksums
d7d049cad5a49e060d9c53e43450ce0f3de8be76652cfd5368d7540146fe22f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for posthog-otel-exporter 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page