This repository was archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
HoneycombConsoleSpanExporter doesn't seem to work with agentless publisher #39
Comments
The code I'm using looks a bit like this: from opentelemetry import trace
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult, SimpleSpanProcessor
from opentelemetry.ext.honeycomb import _translate_to_hny
from libhoney.version import VERSION
from libhoney.internal import json_default_handler
import json
# We use our own implementation, since the main one deletes
class HoneycombConsoleSpanExporter(SpanExporter):
"""Honeycomb console span exporter for the Honeycomb AWS Lambda Instrumentation.
"""
def __init__(
self,
service_name=None,
out=sys.stdout,
dataset=None,
user_agent_addition='',
sample_rate=1,
):
self.out = out
self.service_name = service_name
self.sample_rate = sample_rate
self.dataset = dataset
self.user_agent = "libhoney-py/" + VERSION
if user_agent_addition:
self.user_agent += " " + user_agent_addition
def export(self, spans):
dataset = self.dataset
user_agent = self.user_agent
out = self.out
sample_rate = self.sample_rate
for d in _translate_to_hny(spans):
start_time = d["start_time"]
del d["start_time"]
event_time = start_time.isoformat()
if start_time.tzinfo is None:
event_time += "Z"
# we add dataset and user_agent to the payload
# if processed by another honeycomb agent (i.e. agentless integrations
# for AWS), this data will get used to route the event to the right
# location with appropriate metadata
payload = {
"time": event_time,
"samplerate": sample_rate,
"dataset": dataset,
"user_agent": user_agent,
"data": d,
}
out.write(json.dumps(payload, default=json_default_handler) + os.linesep)
out.flush()
return SpanExportResult.SUCCESS
import os
import sys
dataset = os.environ['HONEYCOMB_DATASET']
service_name = os.environ['HONEYCOMB_SERVICE_NAME']
exporter = HoneycombConsoleSpanExporter(
service_name=service_name,
out=sys.stdout,
dataset=dataset,
)
trace.get_tracer_provider().add_span_processor(SimpleSpanProcessor(exporter)) |
Closed
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is there a reason the
HoneycombConsoleSpanExporter
andFileTransmission
are implemented so differently?Compare:
opentelemetry-exporter-python/opentelemetry/ext/honeycomb/__init__.py
Lines 107 to 112 in 9ace0a0
with the corresponding implementation in libhoney-py:
https://github.com/honeycombio/libhoney-py/blob/6cc1e205184ab4a0117e00864fc982656f5cbacc/libhoney/transmission.py#L464-L482
The text was updated successfully, but these errors were encountered: