Microsoftapplicationinsight.dll 以这种方式编辑以使用它离线发布数据到云端
Microsoftapplicationinsight.dll be edited in such a way to use it offline posting data to cloud
我正在离线将数据发布到云 azure。所以通过编辑 dll 我可以做到吗?有什么办法可以编辑dll吗??
是的,这是可能的,但要视情况而定。
场景一
如果您处理的应用程序可能 有时 失去网络连接,那么您可以使用 ServerTelemetryChannel
。
场景 2
如果您想将遥测数据离线存储在一个中心位置,并让一个单独的进程将遥测数据发送到 Application Insigths,那么不,没有开箱即用的解决方案。另见 。
现在,对于第一个场景,这将起作用:
using System;
using System.Threading;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
namespace OfflineApplicationInsights
{
class Program
{
static void Main(string[] args)
{
var upc = new UsingPersistenceChannel();
upc.Log("Test1");
upc.Log("Test2");
upc.Log("Test3");
upc.Log("Test4");
Console.ReadLine();
upc.Flush();
Thread.Sleep(2000);
}
}
public class UsingPersistenceChannel
{
private readonly TelemetryClient _client;
public UsingPersistenceChannel()
{
var config = new TelemetryConfiguration("[your key here]");
var telemetryChannel = new ServerTelemetryChannel
{
StorageFolder = @"C:\Temp\ai-offline",
DeveloperMode = false,
MaxTelemetryBufferCapacity = 1
};
config.TelemetryChannel = telemetryChannel;
telemetryChannel.Initialize(config);
_client = new TelemetryClient(config)
{
InstrumentationKey = "[your key here]"
};
}
public void Log(string msg)
{
_client.TrackTrace(msg);
}
public void Flush()
{
_client.Flush();
}
}
}
但是,a bug 有时会阻止此操作。对我来说,它只有在我通过 Control Panel\Network 和 Internet\Network Connections
使用 Windows 配置面板禁用(!)所有网络适配器时才有效
如果您要禁用网络和 运行 这个程序,您会看到一些文件出现在指定的文件夹中。再次恢复网络和 运行 应用程序,您会注意到文件将消失,因为一旦检测到网络 activity,它们就会被程序拾取并发送。至少我是这样测试的。
我正在离线将数据发布到云 azure。所以通过编辑 dll 我可以做到吗?有什么办法可以编辑dll吗??
是的,这是可能的,但要视情况而定。
场景一
如果您处理的应用程序可能 有时 失去网络连接,那么您可以使用 ServerTelemetryChannel
。
场景 2
如果您想将遥测数据离线存储在一个中心位置,并让一个单独的进程将遥测数据发送到 Application Insigths,那么不,没有开箱即用的解决方案。另见
现在,对于第一个场景,这将起作用:
using System;
using System.Threading;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
namespace OfflineApplicationInsights
{
class Program
{
static void Main(string[] args)
{
var upc = new UsingPersistenceChannel();
upc.Log("Test1");
upc.Log("Test2");
upc.Log("Test3");
upc.Log("Test4");
Console.ReadLine();
upc.Flush();
Thread.Sleep(2000);
}
}
public class UsingPersistenceChannel
{
private readonly TelemetryClient _client;
public UsingPersistenceChannel()
{
var config = new TelemetryConfiguration("[your key here]");
var telemetryChannel = new ServerTelemetryChannel
{
StorageFolder = @"C:\Temp\ai-offline",
DeveloperMode = false,
MaxTelemetryBufferCapacity = 1
};
config.TelemetryChannel = telemetryChannel;
telemetryChannel.Initialize(config);
_client = new TelemetryClient(config)
{
InstrumentationKey = "[your key here]"
};
}
public void Log(string msg)
{
_client.TrackTrace(msg);
}
public void Flush()
{
_client.Flush();
}
}
}
但是,a bug 有时会阻止此操作。对我来说,它只有在我通过 Control Panel\Network 和 Internet\Network Connections
使用 Windows 配置面板禁用(!)所有网络适配器时才有效如果您要禁用网络和 运行 这个程序,您会看到一些文件出现在指定的文件夹中。再次恢复网络和 运行 应用程序,您会注意到文件将消失,因为一旦检测到网络 activity,它们就会被程序拾取并发送。至少我是这样测试的。