A space in Arize allows the grouping of different model uses cases. Inside a space you can have multiple Model IDs or use cases.
The lowest level logical separation of traces in Arize is currently done by a Model ID which acts as a use case based separator of data. A model ID acts as a project to capture trace data for a specific model application.
# Import open-telemetry dependenciesfrom arize_otel import register_otel, Endpoints# Setup OTEL via our convenience function.register_otel( endpoints = Endpoints.ARIZE, space_id ="your-space-id", # in app space settings page api_key ="your-api-key", # in app space settings page="your-model-id", # name this to whatever you would like)
The code below shows how to setup tracing to export spans to Arize. To see how to use our auto instrumentations see Tracing Integrations (Auto).
Create an instrumentation.ts file. That file should look like this:
import { registerInstrumentations } from"@opentelemetry/instrumentation";import { ConsoleSpanExporter } from"@opentelemetry/sdk-trace-base";import { NodeTracerProvider, SimpleSpanProcessor,} from"@opentelemetry/sdk-trace-node";import { Resource } from"@opentelemetry/resources";import { OTLPTraceExporter as GrpcOTLPTraceExporter } from"@opentelemetry/exporter-trace-otlp-grpc"; // Arize specificimport { diag, DiagConsoleLogger, DiagLogLevel } from"@opentelemetry/api";import { Metadata } from"@grpc/grpc-js"// For troubleshooting, set the log level to DiagLogLevel.DEBUGdiag.setLogger(newDiagConsoleLogger(),DiagLogLevel.DEBUG);// Arize specific - Create metadata and add your headersconstmetadata=newMetadata();// Your Arize Space and API Keys, which can be found in the UI, see belowmetadata.set('space_id','your-space-id');metadata.set('api_key','your-api-key');constprovider=newNodeTracerProvider({ resource:newResource({// Arize specific - The name of a new or preexisting model you // want to export spans to"model_id":"your-model-id","model_version":"your-model-version" }),});provider.addSpanProcessor(newSimpleSpanProcessor(newConsoleSpanExporter()));provider.addSpanProcessor(newSimpleSpanProcessor(newGrpcOTLPTraceExporter({ url:"https://otlp.arize.com/v1", metadata, }), ),);// Add auto instrumentatons hereprovider.register();
This file needs to run at the entry point of your application, before any other code on your server runs. You can do this by importing it at the top of your entry point for example in something like server/app.ts:
import"./instrumentation"// server startup
Or you can import it via a node command when you run your server as outline in the OpenTelemetry documentation using import or require:
# requirenpxts-node--require./instrumentation.tsapp.ts# importnpxts-node--import./instrumentation.tsapp.ts# Or without ts-node something likenode--import./dist/instrumentation.cjs./dist/index.cjs
The space ID can be found in the space settings tab.
The the spaces can be added or changed at the top of the page.
The model_ID maps to a model use-case it to the models which can be selected by clicking on models in the left navigation bar.