@microsoft/agents-hosting-dialogs 1.5.0-beta.6.ga236d9a19c → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import { metric, MetricNames } from '@microsoft/agents-telemetry'
5
+
6
+ export const DialogsMetrics = {
7
+ contextCount: metric.counter(MetricNames.DIALOGS_CONTEXT_COUNT, {
8
+ unit: 'operations',
9
+ description: 'Total number of dialog context operations'
10
+ }),
11
+
12
+ contextDuration: metric.histogram(MetricNames.DIALOGS_CONTEXT_DURATION, {
13
+ unit: 'ms',
14
+ description: 'Duration of dialog context operations in milliseconds'
15
+ })
16
+ }
@@ -0,0 +1,187 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import { SpanNames, trace } from '@microsoft/agents-telemetry'
5
+ import { DialogsMetrics } from './metrics'
6
+ import { Activity } from '@microsoft/agents-activity'
7
+
8
+ const unknownValue = (value?: string): string => value || 'unknown'
9
+ const defaultActivity = Activity.fromObject({ type: 'unknown' })
10
+
11
+ export const DialogsTraceDefinitions = {
12
+ run: trace.define({
13
+ name: SpanNames.DIALOGS_RUN,
14
+ record: {
15
+ dialogId: '',
16
+ activity: defaultActivity,
17
+ status: 'unknown',
18
+ attemptCount: 0,
19
+ },
20
+ end ({ span, record }) {
21
+ span.setAttributes({
22
+ 'dialog.root_id': unknownValue(record.dialogId),
23
+ 'activity.type': unknownValue(record.activity?.type),
24
+ 'activity.channel_id': unknownValue(record.activity?.channelId),
25
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
26
+ 'dialog.status': unknownValue(record.status),
27
+ 'dialog.attempt_count': record.attemptCount ?? 0,
28
+ })
29
+ }
30
+ }),
31
+
32
+ contextBegin: trace.define({
33
+ name: SpanNames.DIALOGS_CONTEXT_BEGIN,
34
+ record: {
35
+ dialogId: '',
36
+ name: 'unknown',
37
+ parentId: '',
38
+ status: 'unknown',
39
+ activity: defaultActivity,
40
+ },
41
+ end ({ span, record, duration }) {
42
+ const spanAttributes = {
43
+ 'activity.type': unknownValue(record.activity?.type),
44
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
45
+ 'dialog.id': unknownValue(record.dialogId),
46
+ 'dialog.name': unknownValue(record.name),
47
+ 'dialog.parent_id': unknownValue(record.parentId),
48
+ 'dialog.status': unknownValue(record.status),
49
+ }
50
+
51
+ span.setAttributes(spanAttributes)
52
+
53
+ const metricAttributes = {
54
+ operation: 'begin',
55
+ 'result.status': unknownValue(record.status),
56
+ }
57
+
58
+ DialogsMetrics.contextCount.add(1, metricAttributes)
59
+ DialogsMetrics.contextDuration.record(duration, metricAttributes)
60
+ }
61
+ }),
62
+
63
+ contextContinue: trace.define({
64
+ name: SpanNames.DIALOGS_CONTEXT_CONTINUE,
65
+ record: {
66
+ dialogId: '',
67
+ name: 'unknown',
68
+ status: 'unknown',
69
+ activity: defaultActivity,
70
+ },
71
+ end ({ span, record, duration }) {
72
+ const spanAttributes = {
73
+ 'activity.type': unknownValue(record.activity?.type),
74
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
75
+ 'dialog.id': unknownValue(record.dialogId),
76
+ 'dialog.name': unknownValue(record.name),
77
+ 'dialog.status': unknownValue(record.status),
78
+ }
79
+
80
+ span.setAttributes(spanAttributes)
81
+
82
+ const metricAttributes = {
83
+ operation: 'continue',
84
+ 'result.status': unknownValue(record.status),
85
+ }
86
+
87
+ DialogsMetrics.contextCount.add(1, metricAttributes)
88
+ DialogsMetrics.contextDuration.record(duration, metricAttributes)
89
+ }
90
+ }),
91
+
92
+ contextEnd: trace.define({
93
+ name: SpanNames.DIALOGS_CONTEXT_END,
94
+ record: {
95
+ activity: defaultActivity,
96
+ dialogId: '',
97
+ name: 'unknown',
98
+ status: 'unknown',
99
+ },
100
+ end ({ span, record, duration }) {
101
+ const spanAttributes = {
102
+ 'activity.type': unknownValue(record.activity?.type),
103
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
104
+ 'dialog.id': unknownValue(record.dialogId),
105
+ 'dialog.name': unknownValue(record.name),
106
+ 'dialog.status': unknownValue(record.status),
107
+ }
108
+
109
+ span.setAttributes(spanAttributes)
110
+
111
+ const metricAttributes = {
112
+ operation: 'end',
113
+ 'result.status': unknownValue(record.status),
114
+ }
115
+
116
+ DialogsMetrics.contextCount.add(1, metricAttributes)
117
+ DialogsMetrics.contextDuration.record(duration, metricAttributes)
118
+ }
119
+ }),
120
+
121
+ contextReplace: trace.define({
122
+ name: SpanNames.DIALOGS_CONTEXT_REPLACE,
123
+ record: {
124
+ activity: defaultActivity,
125
+ dialogId: '',
126
+ name: 'unknown',
127
+ replacementDialogId: '',
128
+ replacementName: 'unknown',
129
+ status: 'unknown',
130
+ },
131
+ end ({ span, record, duration }) {
132
+ const spanAttributes = {
133
+ 'activity.type': unknownValue(record.activity?.type),
134
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
135
+ 'dialog.id': unknownValue(record.dialogId),
136
+ 'dialog.name': unknownValue(record.name),
137
+ 'dialog.replacement_id': unknownValue(record.replacementDialogId),
138
+ 'dialog.replacement_name': unknownValue(record.replacementName),
139
+ 'dialog.status': unknownValue(record.status),
140
+ }
141
+
142
+ span.setAttributes(spanAttributes)
143
+
144
+ const metricAttributes = {
145
+ operation: 'replace',
146
+ 'result.status': unknownValue(record.status),
147
+ }
148
+
149
+ DialogsMetrics.contextCount.add(1, metricAttributes)
150
+ DialogsMetrics.contextDuration.record(duration, metricAttributes)
151
+ }
152
+ }),
153
+
154
+ contextCancelAll: trace.define({
155
+ name: SpanNames.DIALOGS_CONTEXT_CANCEL_ALL,
156
+ record: {
157
+ activity: defaultActivity,
158
+ cancelParents: false,
159
+ dialogId: '',
160
+ eventName: '',
161
+ name: 'unknown',
162
+ status: 'unknown',
163
+ },
164
+ end ({ span, record, duration }) {
165
+ const spanAttributes = {
166
+ 'activity.type': unknownValue(record.activity?.type),
167
+ 'activity.conversation_id': unknownValue(record.activity?.conversation?.id),
168
+ 'dialog.cancel_parents': record.cancelParents,
169
+ 'dialog.event_name': unknownValue(record.eventName),
170
+ 'dialog.id': unknownValue(record.dialogId),
171
+ 'dialog.name': unknownValue(record.name),
172
+ 'dialog.status': unknownValue(record.status),
173
+ }
174
+
175
+ span.setAttributes(spanAttributes)
176
+
177
+ const metricAttributes = {
178
+ operation: 'cancel_all',
179
+ 'result.status': unknownValue(record.status),
180
+ 'dialog.cancel_parents': record.cancelParents,
181
+ }
182
+
183
+ DialogsMetrics.contextCount.add(1, metricAttributes)
184
+ DialogsMetrics.contextDuration.record(duration, metricAttributes)
185
+ }
186
+ }),
187
+ }