azure / botbuilder-instrumentation-cs Goto Github PK
View Code? Open in Web Editor NEWBotBuilder Instrumentation (C#)
License: MIT License
BotBuilder Instrumentation (C#)
License: MIT License
Hello
I tried to configure the Ibex-Dashboard, but i stocked during the instrumentation part. Configuring ibex dashboard in its basic with application insights, the necessary application id and application instrumentation key worked well. At the moment I can see how many users used the chatbot and on which channels. But to see the Intent Graph and map activity i need to configure the instrumentation part.
I develop on the newest version of BotBuilder.Instrumentation v 1.0.0.44, where Micosoft Bot Builder relies on the version 3.15.3. Moreover, I only use the LUIS Cognitive Services.
Another Source that i used to solve my issue was https://rahulrai.in/post/Visualize-Performance-of-Your-Bots-With-The-Ibex-Dashboard/
What i did so far:
0. State Management installed
Installation of Install-Package BotBuilder.Instrumentation v 1.0.0.44
web.config file adaption
Initialize the bot builder instrumentation in Global.asax
// public readonly BotFrameworkApplicationInsightsInstrumentation DefaultInstrumentation = (BotFrameworkApplicationInsightsInstrumentation) DependencyResolver.Current.DefaultInstrumentationWithCognitiveServices;
I adapt my current code (first part):
[Serializable]
public class MyLuisModelAttribute : LuisModelAttribute
{
public MyLuisModelAttribute() : base(
modelID: ConfigurationSettings.AppSettings.Get("LuisAppId"),
subscriptionKey: ConfigurationSettings.AppSettings.Get("LuisAPIKey"),
domain: ConfigurationSettings.AppSettings.Get("LuisAPIHostName"))
{
}
}
[MyLuisModel]
[Serializable]
public class RootLuisDialog : LuisDialog
{
//Gloable Variablen
private double IntentScoreThreshold = 0.41;
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("Ich habe dich leider nicht verstanden.")
}
With:
[Serializable]
public class RootDialog : InstrumentedLuisDialog
{
public RootDialog(string luisModelId, string luisSubscriptionKey) : base(luisModelId, luisSubscriptionKey)
{
}
// ...
}
After adapting these steps, nothing worked well. Can you give me an advice what the problem could be?
Greetings
Sandro
Hi Team,
The Bot itself is going for toss when deployed in azure, where as it working fine in emulator during the course of development.
In Global.asax.cs file we've setting
var store = new InMemoryDataStore(); // volatile in-memory store
bld.Register(c => store)
.Keyed<IBotDataStore>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
Repro steps:
What you receive is
Details{ "message": "An error has occurred.", "exceptionMessage": "Method not found: 'System.Nullable`1<System.DateTime> Microsoft.Bot.Connector.IActivity.get_Timestamp()'.", "exceptionType": "System.MissingMethodException", "stackTrace": " at BotBuilder.Instrumentation.BotFrameworkApplicationInsightsInstrumentation.BuildEventTelemetry(IActivity activity, IDictionary`2 properties, IDictionary`2 metrics)\r\n at BotBuilder.Instrumentation.BotFrameworkApplicationInsightsInstrumentation.<TrackActivity>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at BotBuilder.Instrumentation.Telemetry.DialogActivityLogger.<LogAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Dialogs.Internals.LogPostToBot.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__11.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at Microsoft.Bot.Sample.SimpleAlarmBot.Controllers.MessagesController.<Post>d__0.MoveNext() in c:\\Code\\Git\\Bot-with-instrumentation-cs-jacek\\SimpleAlarmBot\\Controllers\\MessagesController.cs:line 38\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" }
This is due to timestamp being encoded differently.
Where should be log "MBFEvent.StartTransaction' and "MBFEvent.EndTransaction" events?
I've an issue in LUIS authorization (Exception: Response status code does not indicate success: 401 (Access Denied).). I was looking around and I found one thing:
My LUIS is in westeurope.api.cognitive.microsoft.com domain, I set LuisModel domain to it and so CognitiveServiceApiEndpoint. But when I run the app I get "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" in model.UriBase. ModelID and SubscriptionKey are ok. I've no "westus.api.cognitive.microsoft.com" anywhere in my app.
Hi, I am starting using the library. However, whichever method I try to use (TrackActivity, TrackLuisIntent, TrackCustomEvent, etc..) I got the following exception:
"Method not found: 'System.Nullable`1<System.DateTime> Microsoft.Bot.Connector.IActivity.get_Timestamp()'."
I used the library some months ago with BotBuilder SDK 3.11.0 and it worked fine.
Now I am using the latest BotBuilder SDK 3.14.0.7 and I cannot downgrade.
Is it possible that in the new SDK this method has been removed?
Cheers,
Mirko
Snippet:
private static async Task TrackMessageSentiment(IActivity activity)
{
if (_textAnalyticsApiKey != null)
When I try and use the instrumentation within a dialog I get an error that it cannot be serialized, which makes sense. I have tried registering the service with Autofac, but cannot seem to get this working.
Do you have any examples of using telemetry within a dialog?
Thanks
Gary
Hi,
When trying to use InstrumentedLuisDialog for my LUIS dialog, I'm getting 'Exception thrown: 'System.MissingMethodException' in Microsoft.Bot.Builder.dll' at runtime and abruptly terminates the call. Has anyone encountered this issue as well?
The latest version of the botbuilder package is throwing an exception:
Method not found: 'System.Nullable
1<System.DateTime> Microsoft.Bot.Connector.IActivity.get_Timestamp()'.`
This is the stacktrace:
at BotBuilder.Instrumentation.BotFrameworkApplicationInsightsInstrumentation.BuildEventTelemetry(IActivity activity, IDictionary
2 properties, IDictionary2 metrics) at BotBuilder.Instrumentation.BotFrameworkApplicationInsightsInstrumentation.TrackLuisIntent(IActivity activity, LuisResult result) at VTChatbot.Dialogs.BasicLuisDialog.DispatchToIntentHandler(IDialogContext context, IAwaitable
1 item, IntentRecommendation bestIntent, LuisResult result) in C:_TFSRemote\VT Chatbot\src\dev\VTChatbot\Dialogs\BasicLuisDialog.cs`
When I install version 3.8.3.0 of the Microsoft.Bot.Builder package, I don't get the exception.
I have my bot published in facebook and web and everything work fine. But the problem is when i stop to talk to the bot after 5 hours more or less and i return to talk to the bot again i have this exception The requested service 'BotBuilder.Instrumentation.Interfaces.IBotFrameworkInstrumentation' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency. and to fix this i have to delete the conversation on facebook and talk it again and it works, another thing is that problem is just in facebook in the web chat i dont have problem maybe because i m using directline. I have this code in my IoC
This my autofac class to inject things i need
public static void Configure()
{
var builder = new ContainerBuilder();
#region Modules
builder.RegisterModule(new DialogModule());
#endregion
#region Dialogs
builder.RegisterType<RootDialog>().As<LuisRootDialog<object>>().InstancePerDependency();
#endregion
#region Factory
builder.RegisterType<DialogFactory>().Keyed<IDialogFactory>(FiberModule.Key_DoNotSerialize).AsImplementedInterfaces().SingleInstance();
builder.RegisterType<TicketFactory>().Keyed<ITicketFactory>(FiberModule.Key_DoNotSerialize).AsImplementedInterfaces().SingleInstance();
#endregion
#region Database
builder.RegisterGeneric(typeof(DocumentService<>)).As(typeof(IDocumentDbService<>)).SingleInstance();
#endregion
#region Web Api Registration
var config = GlobalConfiguration.Configuration;
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(config);
#endregion
#region Autofac Container
builder.Update(container: Conversation.Container);
config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
#endregion
}
And this is my message controller where i resolve my root controller
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
try
{
LogMessage("Before Open Dialogs");
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
{
await Conversation.SendAsync(activity, () => scope.Resolve<LuisRootDialog<object>>());
}
}
catch (Exception ex)
{
LogMessage("Error a Nivel de Abrir el Dialog");
LogMessage(ex.Message);
}
}
else
{
await HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
This is part of my RootDialog
[Serializable]
public class RootDialog : LuisRootDialog<object>
{
#region Properties
public string Text { get; set; }
#endregion
#region Declarations
readonly IDialogFactory _dialogFactory;
#endregion
#region Constructor
public RootDialog(IDialogFactory dialogFactory
) :
base(LuisRootConstants.MODELID, LuisConstants.SUSBSCRIPTION)
{
SetField.NotNull(out _dialogFactory, nameof(dialogFactory), dialogFactory);
}
#endregion
#region Luis Intents
[LuisIntent(LuisConstants.NONE)]
public async Task None(IDialogContext context, LuisResult result)
{
await Util.GenerateReplying(context);
if (result.Query.ToLower().Contains(GeneralConstants.HUMAN_ACCESS))
{
await context.PostAsync("Disculpe los inconvenientes, en este momento no tenemos asesores disponibles para atención.");
context.Call(new TicketDialog(_createTicketCommand), TicketDialogResumeAfter);
}
else
{
await context.PostAsync("Disculpa los inconvenientes, pero no puedo entenderte.");
context.Wait(MessageReceived);
}
}
#endregion
#region Methods
protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
{
var message = await item;
Text = message.Text.ToLowerInvariant();
await base.MessageReceived(context, item);
}
#endregion
}
And here is the instrumentations inheritance.
[Serializable]
public class LuisRootDialog<R> : InstrumentedLuisDialog<object>
{
public LuisRootDialog(string luisModelId, string luisSubscriptionKey) : base(luisModelId, luisSubscriptionKey)
{
}
}
I hope somebody can help me with this because i cant find the way to make work this without deleting the conversation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.