问题描述
您好,是否可以从单个应用程序向多个AI目的地发送AI遥测?我们有一个供应商创建的应用程序,它将遥测发送到AI的供应商实例,但我们也希望将相同的遥测发送到我们的AI实例。这可能吗?
Hello, is it possible to send AI telemetry to multiple AI destinations from a single app? We have a vendor created application that sends telemetry to the vendor instance of AI but we also want the same telemetry sent to our AI instance. Is this possible?
推荐答案
如果你正在寻找所有东西的硬拷贝,你可以利用几个遥测接收器并使用一个仪器在第二个遥测接收器中使用第二个仪器键时键入第一个接收器,一个客户端将在相同的
时间写入两个自动收集和自定义遥测:
If you are looking for a hard-copy of everything, you can leverage couple Telemetry Sinks and use one Instrumentation Key in the first sink while using the second Instrumentation Key in the second Telemetry Sink, one client will write to both at the same time for the auto-collected and custom telemetry:
namespace AiMultiSink
{
class Program
{
static void Main(string[] args)
{
var config = TelemetryConfiguration.Active;
var channel1 = new InMemoryChannel();
config.DefaultTelemetrySink.TelemetryChannel = channel1;
var chainBuilder1 = new TelemetryProcessorChainBuilder(config, config.DefaultTelemetrySink);
chainBuilder1.Use((next) =>
{
var p1 = new StubTelemetryProcessor(next);
p1.OnProcess = (telemetry) => { telemetry.Context.InstrumentationKey = "afefc2f8-62c5-449c-a604-15bf92c79d53"; };
return p1;
});
config.DefaultTelemetrySink.TelemetryProcessorChainBuilder = chainBuilder1;
var channel2 = new InMemoryChannel();
var sink2 = new TelemetrySink(config, channel2);
config.TelemetrySinks.Add(sink2);
var chainBuilder2 = new TelemetryProcessorChainBuilder(config, sink2);
chainBuilder2.Use((next) =>
{
var p2 = new StubTelemetryProcessor(next);
p2.OnProcess = (telemetry) => { telemetry.Context.InstrumentationKey = "c52e4c3e-6045-49d3-adae-1346fc0a2431"; };
return p2;
});
sink2.TelemetryProcessorChainBuilder = chainBuilder2;
var client = new TelemetryClient(config);
client.TrackTrace("foo");
channel1.Flush();
channel2.Flush();
Console.WriteLine("Press any key to exit");
Console.ReadKey(intercept: true);
}
}
public sealed class StubTelemetryProcessor : ITelemetryProcessor, IDisposable
{
private ITelemetryProcessor next;
public StubTelemetryProcessor(ITelemetryProcessor next)
{
this.next = next;
this.OnDispose = () => { };
this.OnProcess = (unusedTelemetry) => { };
}
public Action<ITelemetry> OnProcess { get; set; }
public Action OnDispose { get; set; }
public void Process(ITelemetry telemetry)
{
this.OnProcess(telemetry);
if (this.next != null)
{
this.next.Process(telemetry);
}
}
public void Dispose()
{
this.OnDispose();
}
}
}
这篇关于单个应用程序,多个应用程序洞察目的地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!