diff --git a/examples/observability/simple_calculator_observability/configs/config-futureagi.yml b/examples/observability/simple_calculator_observability/configs/config-futureagi.yml new file mode 100644 index 0000000000..0791a5b188 --- /dev/null +++ b/examples/observability/simple_calculator_observability/configs/config-futureagi.yml @@ -0,0 +1,69 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +general: + telemetry: + logging: + console: + _type: console + level: WARN + file: + _type: file + path: ./.tmp/nat_simple_calculator.log + level: DEBUG + tracing: + futureagi: + _type: futureagi + endpoint: https://api.futureagi.com/tracer/v1/traces + project: simple_calculator + fi_api_key: ${FI_API_KEY} + fi_secret_key: ${FI_SECRET_KEY} + project_version_name: "1.0.0" + +functions: + calculator_multiply: + _type: calculator_multiply + calculator_inequality: + _type: calculator_inequality + calculator_divide: + _type: nat_simple_calculator/calculator_divide + current_datetime: + _type: current_datetime + calculator_subtract: + _type: calculator_subtract + +llms: + nim_llm: + _type: nim + model_name: meta/llama-3.1-70b-instruct + temperature: 0.0 + max_tokens: 1024 + openai_llm: + _type: openai + model_name: gpt-3.5-turbo + max_tokens: 2000 + +workflow: + _type: react_agent + tool_names: + - calculator_multiply + - calculator_inequality + - current_datetime + - calculator_divide + - calculator_subtract + llm_name: nim_llm + verbose: true + parse_agent_response_max_retries: 3 diff --git a/packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/register.py b/packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/register.py index 3a12ed79c2..3cbe13cdf1 100644 --- a/packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/register.py +++ b/packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/register.py @@ -15,6 +15,7 @@ import logging import os +from typing import Any from pydantic import Field @@ -192,3 +193,55 @@ async def galileo_telemetry_exporter(config: GalileoTelemetryExporter, builder: drop_on_overflow=config.drop_on_overflow, shutdown_timeout=config.shutdown_timeout, ) + + +class FutureAGITelemetryExporter(BatchConfigMixin, CollectorConfigMixin, TelemetryExporterBaseConfig, name="futureagi"): + """A telemetry exporter to transmit traces to Future AGI service.""" + + endpoint: str = Field(description="The Future AGI endpoint to export telemetry traces", + default="https://api.futureagi.com/tracer/v1/traces") + fi_api_key: str = Field(description="The FutureAGI API key", default="") + fi_secret_key: str = Field(description="The FutureAGI Secret key", default="") + project_type: str = Field(description="The project type for FutureAGI instrumentation", default="observe") + project_version_name: str = Field(description="The project version name", default="1.0.0") + resource_attributes: dict[str, Any] = Field(default_factory=dict, + description="The resource attributes to add to the span") + + +@register_telemetry_exporter(config_type=FutureAGITelemetryExporter) +async def futureagi_telemetry_exporter(config: FutureAGITelemetryExporter, builder: Builder): + """Create a FutureAGI telemetry exporter.""" + import json + import uuid + + from nat.plugins.opentelemetry import OTLPSpanAdapterExporter + + api_key = config.fi_api_key or os.environ.get("FI_API_KEY") + secret_key = config.fi_secret_key or os.environ.get("FI_SECRET_KEY") + + if not api_key or not secret_key: + raise ValueError("API key and Secret key are required for FutureAGI") + + headers = {"x-api-key": api_key, "x-secret-key": secret_key} + + project_version_id = str(uuid.uuid4()) + + default_resource_attributes = { + "project_name": config.project, + "project_type": config.project_type.lower(), + "project_version_name": config.project_version_name, + "project_version_id": project_version_id, + "eval_tags": json.dumps([]), + "metadata": json.dumps({}) + } + + merged_resource_attributes = {**default_resource_attributes, **config.resource_attributes} + + yield OTLPSpanAdapterExporter(endpoint=config.endpoint, + headers=headers, + resource_attributes=merged_resource_attributes, + batch_size=config.batch_size, + flush_interval=config.flush_interval, + max_queue_size=config.max_queue_size, + drop_on_overflow=config.drop_on_overflow, + shutdown_timeout=config.shutdown_timeout)