HubPublic

Integrations

Connect LangSmith and Langfuse traces as OTel answer evidence

Keep LangSmith, Langfuse, or your own OpenTelemetry runtime as the trace system. Send rawctx only the public-safe fields needed to connect that trace to answer-audit logs, source_refs, and semantic_refs.

This integration does not replace LangSmith or Langfuse. Your observability workspace still owns spans, prompts, tool calls, latency, and cost analysis. rawctx records the evidence object your team can attach to an answer review, and does not claim the submitted OTel trace content is true.

The public boundary has two paths in code: SDK ingest_otel_trace_bundle() wraps one trace bundle into an answer-audit log, while POST /api/answer-audit-logs/otel maps OTLP-style resourceLogs or resourceSpans into answer-audit records.

LangSmith boundary

Send trace ids, run ids, service name, redacted or hashed question and answer fields, and package refs to rawctx. Do not send LangSmith API keys or private project URLs.

Langfuse boundary

Keep Langfuse as the trace store and observability workspace. Link only trace ids and answer-audit fields through source_refs, excluding secret keys and raw tool outputs.

Your OTel runtime

If your collector or exporter already emits OTLP payloads, add the rawctx custom attributes you need. A separate rawctx-specific agent runtime is not required.

SDK

Wrap one trace bundle as an answer-audit log

Use this path when you extract public-safe identifiers and hashes from a trace already recorded in LangSmith or Langfuse.

rawctx
import rawctx

trace_bundle = {
    "resourceSpans": [
        {
            "resource": {
                "attributes": [
                    {"key": "service.name", "value": {"stringValue": "support-assistant"}},
                    {"key": "deployment.environment", "value": {"stringValue": "production"}},
                ]
            },
            "scopeSpans": [
                {
                    "spans": [
                        {
                            "traceId": "4f3c2b1a0f9e8d7c6b5a493827160504",
                            "spanId": "7a6b5c4d3e2f1001",
                            "name": "llm.answer",
                            "attributes": [
                                {
                                    "key": "rawctx.audit.application_key",
                                    "value": {"stringValue": "support_assistant"},
                                },
                                {
                                    "key": "rawctx.audit.idempotency_key",
                                    "value": {"stringValue": "support_assistant:req_123:msg_456"},
                                },
                                {
                                    "key": "gen_ai.request.model",
                                    "value": {"stringValue": "gpt-4o"},
                                },
                            ],
                        }
                    ]
                }
            ],
        }
    ]
}

rawctx.ingest_otel_trace_bundle(
    application_key="support_assistant",
    environment="production",
    trace_bundle=trace_bundle,
    external_trace_id="4f3c2b1a0f9e8d7c6b5a493827160504",
    external_message_id="msg_456",
    question={"hash": "sha256:235d0f0faf774748394fbb5dec9c41c51ac23b1cc6c344bc06864e7d34442516"},
    answer={"hash": "sha256:f564d7fd469050a37898846611c9a6031be9bad19907812ec0d605b3e614b6f8"},
    semantic_refs=[
        {
            "package_ref": "@acme/support-policy",
            "package_version": "1.4.2",
            "context_hash": "sha256:context_hash",
        }
    ],
    source_refs=[
        {
            "source_type": "langsmith_trace",
            "trace_id": "4f3c2b1a0f9e8d7c6b5a493827160504",
        }
    ],
    registry="https://hub.rawctx.dev",
)

OTLP

Map spans or log records directly through the API

Use this from a collector, gateway, or queue service that forwards OTLP-shaped payloads. Each record needs a service name or application key.

rawctx
POST /api/answer-audit-logs/otel
Content-Type: application/json

{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {"key": "service.name", "value": {"stringValue": "support_assistant"}},
          {"key": "deployment.environment", "value": {"stringValue": "production"}}
        ]
      },
      "scopeSpans": [
        {
          "spans": [
            {
              "traceId": "4f3c2b1a0f9e8d7c6b5a493827160504",
              "spanId": "7a6b5c4d3e2f1001",
              "attributes": [
                {
                  "key": "rawctx.audit.idempotency_key",
                  "value": {"stringValue": "support_assistant:req_123:msg_456"}
                },
                {
                  "key": "rawctx.audit.semantic_refs",
                  "value": {
                    "stringValue": "[{\"package_ref\":\"@acme/support-policy\",\"package_version\":\"1.4.2\"}]"
                  }
                },
                {
                  "key": "rawctx.audit.source_refs",
                  "value": {
                    "stringValue": "[{\"source_type\":\"langfuse_trace\",\"trace_id\":\"4f3c2b1a0f9e8d7c6b5a493827160504\"}]"
                  }
                },
                {
                  "key": "gen_ai.input.messages",
                  "value": {"stringValue": "[{\"role\":\"user\",\"content\":\"hash or redacted text\"}]"}
                },
                {
                  "key": "gen_ai.output.messages",
                  "value": {"stringValue": "[{\"role\":\"assistant\",\"content\":\"hash or redacted text\"}]"}
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Field mapping

Public-safe OTel fields rawctx reads

These fields are enough to connect an answer, context, trace identifier, and review state. Use hashes instead of text unless your retention policy allows raw text storage.

Application
service.namerawctx.audit.application_keydeployment.environment
Trace link
traceIdspanIdrawctx.audit.idempotency_keyrawctx.audit.external_message_id
Answer evidence
rawctx.audit.semantic_refsrawctx.audit.source_refsrawctx.audit.inference_commitmentgen_ai.input.messagesgen_ai.output.messages
User boundary
enduser.id_hashsession.id_hash

Public-safe scope

What not to send

rawctx needs evidence links for answer review. It does not need to mirror observability secrets or raw customer content by default.

  • Do not include LANGSMITH_API_KEY, LANGFUSE_SECRET_KEY, collector tokens, or private trace URLs in the payload.
  • Register raw prompts, tool outputs, customer files, or call recordings as separate evidence assets only when retention policy and review access are ready.
  • Prefer sha256 hashes plus trace ids when that is enough for support, security, or legal review.