HubPublic

Integrations

Attach LangSmith and Langfuse trace references through OTel

LangSmith, Langfuse, or your own OpenTelemetry runtime remains the trace system. Choose the public-safe trace IDs, hashes, and references to attach through answer-audit source_refs.

This reference attachment is not a connector that replaces or automatically synchronizes LangSmith or Langfuse. Your observability workspace still owns spans, prompts, tool calls, latency, and cost analysis. You select the public-safe fields to submit, and rawctx does not claim the submitted OTel trace content is true.

The authenticated ingestion API has two paths. 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.

These SDK and OTLP examples call https://api.rawctx.dev directly. The Hub browser's same-origin BFF at https://hub.rawctx.dev/api/bff is for browser sessions and is not an SDK registry.

Data from LangSmith

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.

Data from Langfuse

Langfuse stores the traces and provides observability analysis. 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 a user-selected 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"},
    source_refs=[
        {
            "source_type": "langsmith_trace",
            "trace_id": "4f3c2b1a0f9e8d7c6b5a493827160504",
        }
    ],
    registry="https://api.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 https://api.rawctx.dev/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.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.source_refsrawctx.audit.inference_commitmentgen_ai.input.messagesgen_ai.output.messages
User identifiers
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.