Hi Everyone, I am sending the metric in signoz usi...
# support
h
Hi Everyone, I am sending the metric in signoz using lambda
Copy code
def base_lambda_handler(event, context):
        counter = meter.create_counter(
            name="sachin_test",
            description="A counter metric for SigNoz",
        )

        # Record a Value
        counter.add(1, {"environment": "production"})
        counter.add(200, {"environment": "production"})
        counter.add(100, {"environment": "production"})
        histogram = meter.create_histogram(
            name="Nitish-metric-histogram",
            description="A histogram metric for value distribution",
        )

        # Record values
        histogram.record(1, {"environment": "production"})
        histogram.record(200, {"environment": "production"})
        histogram.record(100, {"environment": "production"})

    except Exception as e:
        logger.error(f"Error processing SQS event: {str(e)}")
        raise  # Raise to ensure this record is retried and can go to DLQ
    finally:
        # Flush the traces before the lambda function exits
        current_span.end()
        flush_traces()
        time.sleep(5)
tracing.py
Copy code
import os
from opentelemetry import trace, metrics
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.id_generator import RandomIdGenerator
from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.aws import AwsXRayPropagator
from common.logger import get_json_logger

# Initialize logger
logger = get_json_logger("Otel Tracing and Metrics")

# Global variables for tracer and meter
tracer = None
meter = None


def setup_opentelemetry_traces(service_name):
    logger.info(f"Starting OpenTelemetry configuration for service: {service_name}")
    global tracer

    # Set up AWS X-Ray Propagator for trace propagation (only need to set this once)
    set_global_textmap(AwsXRayPropagator())

    # Set resource attributes (service name and environment)
    resource_attributes = {"service.name": service_name}
    if os.environ.get("OTEL_RESOURCE_ATTRIBUTES"):
        resource_attributes = None  # Use resource attributes from environment variables
    resource = Resource.create(attributes=resource_attributes)

    # Configure tracing with OTLP exporter
    otlp_span_exporter = OTLPSpanExporter(
        endpoint=os.getenv("OTEL_ENDPOINT"),
        insecure=True,
        headers={"x-honeycomb-team": os.getenv("HONEYCOMB_API_KEY", "")},
    )
    tracer = TracerProvider(
        resource=resource,
        active_span_processor=BatchSpanProcessor(otlp_span_exporter),
        id_generator=RandomIdGenerator(),
    )
    trace.set_tracer_provider(tracer)
    logger.info("Tracer provider and span processor configured successfully.")

    # Configure metrics with OTLP exporter
    otlp_metric_exporter = OTLPMetricExporter(
        endpoint=os.getenv("OTEL_ENDPOINT"),
        insecure=True,
        headers={"x-honeycomb-team": os.getenv("HONEYCOMB_API_KEY", "")},
    )
    global meter
    metric_reader = PeriodicExportingMetricReader(otlp_metric_exporter)
    meter = MeterProvider(metric_readers=[metric_reader])
    metrics.set_meter_provider(meter)
    logger.info("Meter provider and metric exporter configured successfully.")


def flush_traces():
    """Flush any buffered traces immediately."""
    if tracer:
        tracer.force_flush()
    if meter:
        meter.force_flush()
But in signoz dashboard, I am only able to see the metric Name, not the data points
msg: "No DATA"
Copy code
{
  "level": "INFO",
  "timestamp": "2025-01-07T12:51:58.087Z",
  "caller": "utils/time.go:17",
  "msg": "Elapsed time",
  "func_name": "GetTimeSeriesResultV3",
  "duration": 24,
  "query": "SELECT ts, sum(per_series_value) as value FROM (SELECT  ts, If((per_series_value - lagInFrame(per_series_value, 1, 0) OVER rate_window) < 0, nan, If((ts - lagInFrame(ts, 1, toDate('1970-01-01')) OVER rate_window) >= 86400, nan, (per_series_value - lagInFrame(per_series_value, 1, 0) OVER rate_window) / (ts - lagInFrame(ts, 1, toDate('1970-01-01')) OVER rate_window))) as per_series_value FROM (SELECT fingerprint,  toStartOfInterval(toDateTime(intDiv(unix_milli, 1000)), INTERVAL 60 SECOND) as ts, max(value) as per_series_value FROM signoz_metrics.distributed_samples_v4 INNER JOIN (SELECT DISTINCT fingerprint FROM signoz_metrics.time_series_v4_6hrs WHERE metric_name = 'example_counter' AND temporality = 'Cumulative' AND unix_milli >= 1736229600000 AND unix_milli < 1736254260000) as filtered_time_series USING fingerprint WHERE metric_name = 'example_counter' AND unix_milli >= 1736232600000 AND unix_milli < 1736254260000 GROUP BY fingerprint, ts ORDER BY fingerprint, ts) WINDOW rate_window as (PARTITION BY fingerprint ORDER BY fingerprint, ts)) WHERE isNaN(per_series_value) = 0 GROUP BY ts ORDER BY ts ASC",
  "alertID": "",
  "servicesTab": "",
  "email": "hmurdia@xyz.com",
  "dashboardID": "ff097932-505a-49e4-b9f5-f01826f87c46",
  "source": "dashboards",
  "client": "browser",
  "viewName": "",
  "path": "/dashboard/ff097932-505a-49e4-b9f5-f01826f87c46/new"
}
Clickhouse query -->
Copy code
SELECT ts, sum(per_series_value) as value FROM (SELECT  ts, If((per_series_value - lagInFrame(per_series_value, 1, 0) OVER rate_window) < 0, nan, If((ts - lagInFrame(ts, 1, toDate('1970-01-01')) OVER rate_window) >= 86400, nan, (per_series_value - lagInFrame(per_series_value, 1, 0) OVER rate_window) / (ts - lagInFrame(ts, 1, toDate('1970-01-01')) OVER rate_window))) as per_series_value FROM (SELECT fingerprint,  toStartOfInterval(toDateTime(intDiv(unix_milli, 1000)), INTERVAL 60 SECOND) as ts, max(value) as per_series_value FROM signoz_metrics.distributed_samples_v4 INNER JOIN (SELECT DISTINCT fingerprint FROM signoz_metrics.time_series_v4_6hrs WHERE metric_name = 'example_counter' AND temporality = 'Cumulative' AND unix_milli >= 1736229600000 AND unix_milli < 1736254260000) as filtered_time_series USING fingerprint WHERE metric_name = 'example_counter' AND unix_milli >= 1736232600000 AND unix_milli < 1736254260000 GROUP BY fingerprint, ts ORDER BY fingerprint, ts) WINDOW rate_window as (PARTITION BY fingerprint ORDER BY fingerprint, ts)) WHERE isNaN(per_series_value) = 0 GROUP BY ts ORDER BY ts ASC
this is getting triggered in backend in signoz when we try to find the metrics data in this `signoz_metrics.distributed_samples_v4`table don’t have data points which is weird because as per documentation it should work seamlessly any leads will be helpful, I'm trying the same with lambdas and standalone same result in both the cases
s
Are traces working?
h
yes
we are able to see traces and host metrics
@Srikanth Chekuri any update on this ? are you able to check this ? in clickhouse db table are you able to observe the counter data points ? I'm checking this with a simple counter metric code there also it is visible
With honeycomb it is working as expected
Copy code
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.metrics import Counter
import time

# Honeycomb API endpoint
HONEYCOMB_ENDPOINT = "<http://10.0.0.19:4317>"

# Set up OTLP Metric Exporter
exporter = OTLPMetricExporter(
    endpoint=HONEYCOMB_ENDPOINT
)

# Create a Metric Reader
metric_reader = PeriodicExportingMetricReader(exporter, export_interval_millis=5000)

# Set up the MeterProvider
provider = MeterProvider(metric_readers=[metric_reader])
meter = provider.get_meter("example-meter")

# Register a Counter
counter = meter.create_counter(
    name="example_counter",
    description="A simple counter metric",
    unit="1",
)

# Record some data
def send_metrics():
    for i in range(10):
        print(f"Sending metric {i+1}")
        counter.add(1, {"key": "value"})
        time.sleep(1)  # Wait 1 second before the next metric

if __name__ == "__main__":
    send_metrics()
    print("Metrics sent. Waiting for export...")
    time.sleep(10)  # Wait for metrics to be exported
s
I couldn't reproduce this. Are you saying you see data in honeycomb for metrics but not signoz?
h
yes
s
Are you sure you are sending data to both SigNoz and honeycomb?
h
I tried sending data to the SigNoz collector (native to SigNoz) and then to our standalone collector, which collects all traces and metrics. Our standalone collector’s config file includes both Honeycomb and SigNoz. We upgraded SigNoz to version 0.64 while debugging to see if the issue was resolved in the latest version, but we still couldn’t see the counter metrics.
s
I couldn't comprehend. Can you rephrase
Hi @Hardik Murdia, I won't be able to take calls. I would prefer text communication.
h
hi @Srikanth Chekuri I have rephrased it above can you please check
if needed I can put in the script and details wrt config by tomorrow to debug this further
s
Set this env
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
and try again
h
ok will try this for sure