Skip to content

Commit 63383ef

Browse files
authored
AzureMonitor: Application Insights Traces (grafana#64859)
* Build out barebones Traces editor - Add Traces query type and operation ID prop to query type - Add necessary header types - Update resource picker to appropriately work with traces query type - Build out TracesQueryEditor component - Include logic to retrieve operationId's for AI Workspaces - Add backend route mapping - Update macro to use timestamp as default time field for traces * AzureMonitor: Traces - Response parsing (grafana#65442) * Update FormatAsField component - Add trace ResultFormat type - Generalise FormatAsField component - Add component to TracesQueryEditor - Remove duplicate code in setQueryValue * Add custom filter function to improve performance * Add basic conversion for logs to trace - Add serviceTags converter - Pass through required parameters (queryType and resultFormat) - Appropriately set visualisation * Update parsing to also fill trace tags - Add constant values for each table schema (include legacy mapping for now if needed) - Add constant for list of table tags - Set the foundation for dynamic query building - Update query to build tags value - Appropriately set operationName - Update tagsConverter to filter empty values * Fix lint and test issues * AzureMonitor: Traces - Data links (grafana#65566) * Add portal link for traces - Pull out necessary values (itemId and itemType) - Appropriately construct - Fix ordering * Set default format as value - Also set default visualisation * Fix event schema * Set default formatAsField value * Include logs link on traces results - Adapt config links to allow custom title to be set * Correctly set operationId for query * Update backend types - Include OperationID in query - Pass forward datasource name and UID * Ensure setTime doesn't consistently get called if operationID is defined * Add explore link - Update util functions to allow setting custom datalinks * Fix tests * AzureMonitor: Traces - Query and Editor updates (grafana#66076) * Add initial query - Will query the resource as soon as a resource has been selected - Updates the data links for the query without operationId - Remove initial operationId query and timeRange dependency - Update query building * Add entirely separate traces query property - Update shared types (also including future types for Azure traces) - Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries - Update backend specific types - Update frontend datasource for new properties - Update mock query * Update FormatAsField to be entirely generic * Update query building to be done in backend - Add required mappings in backend - Update frontend querying * Fix query and explore data link * Add trace type selection * Better method for setting explore link * Fix operationId updating * Run go mod tidy * Unnecessary changes * Fix tests * AzureMonitor: Traces - Add correlation API support (grafana#65855) Add correlation API support - Add necessary types - Add correlation API request when conditions are met - Update query * Fix property from merge * AzureMonitor: Traces - Filtering (grafana#66303) * Add initial query - Will query the resource as soon as a resource has been selected - Updates the data links for the query without operationId - Remove initial operationId query and timeRange dependency - Update query building * Add entirely separate traces query property - Update shared types (also including future types for Azure traces) - Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries - Update backend specific types - Update frontend datasource for new properties - Update mock query * Update FormatAsField to be entirely generic * Update query building to be done in backend - Add required mappings in backend - Update frontend querying * Fix query and explore data link * Add trace type selection * Better method for setting explore link * Fix operationId updating * Run go mod tidy * Unnecessary changes * Fix tests * Start building out Filters component - Configure component to query for Filter property values when a filter property is set - Add setFilters function - Add typing to tablesSchema - Use component in TracesQueryEditor * Update Filters - Asynchronously pull property options - Setup list of Filter components * Update filters component - Remove unused imports - Have local filters state and query filters - Correctly set filters values - Don't update query every time a filter property changes (not performant) * Update properties query - Use current timeRange - Get count to provide informative labels * Reset map when time changes * Add operation selection * Reset filters when property changes * Appropriate label name for empty values * Add filtering to query * Update filter components - Fix rendering issue - Correctly compare and update timeRange - Split out files for simplicity * Add checkbox option to multiselect - Add custom option component - Correctly call onChange - Add variableOptionGroup for template variable selection * Fix adding template vars * Improve labels and refresh labels on query prop changes * AzureMonitor: Traces - Testing (grafana#66474) * Select ds for template variable interpolation * Update az logs ds tests - Add templateVariables test - Add filter test - Update mock - Remove anys * Update QueryEditor test - Update mocks with timeSrv for log analytics datasource - Fix query mock - Use appropriate and consistent selectors * Add TracesQueryEditor test - Update resourcePickerRows mock to include app insights resources - Remove comments and extra new line * Add FormatAsField test - Remove unneeded condition * Update resourcePicker utils test * Don't hide selected options in filters * Fix multi-selection on filters * Add TraceTypeField test - Add test file - Update selectors (remove copy/paste mistake) - Update placeholder text for select and add label * Add basic filters test * Begin filters test * Update filters test * Add final tests and simplify/generalise addFilter helper * Minor update to datasource test * Update macros test * Update selectors in tests * Add response-table-frame tests * Add datasource tests - Use sorting where JSON models are inconsistent - Update filters clause - Dedupe tags - Correct operationId conditions * Don't set a default value for blurInputOnSelect * Simplify datasource test * Update to use CheckGoldenJSON utils - Update with generated frame files - Remove redundant expected frame code - Update all usages * Fix lint * AzureMonitor: Traces feedback (grafana#67292) * Filter traces if the visualisation is set to trace - Update build query logic - Added additional test cases - Return an error if the traces type is set by itself with the trace visualisation - Add descriptions to event types - Update tests * Fix bug for error displaying traces * Update mappings and add error field - Update tests - Remove unnecessary comments * Switch location of Operation ID field * Re-order fields * Update link title * Update label for event type selection * Update correct link title * Update logs datalink to link to Azure Logs in explore * Fix lint
1 parent 60c4e71 commit 63383ef

File tree

83 files changed

+7585
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+7585
-560
lines changed

.betterer.results

+1-2
Original file line numberDiff line numberDiff line change
@@ -3779,8 +3779,7 @@ exports[`better eslint`] = {
37793779
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts:5381": [
37803780
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
37813781
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
3782-
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
3783-
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
3782+
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
37843783
],
37853784
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.ts:5381": [
37863785
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],

packages/grafana-ui/src/components/Select/SelectBase.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function SelectBase<T>({
9393
'aria-label': ariaLabel,
9494
autoFocus = false,
9595
backspaceRemovesValue = true,
96+
blurInputOnSelect,
9697
cacheOptions,
9798
className,
9899
closeMenuOnSelect = true,
@@ -213,6 +214,7 @@ export function SelectBase<T>({
213214
'aria-label': ariaLabel,
214215
autoFocus,
215216
backspaceRemovesValue,
217+
blurInputOnSelect,
216218
captureMenuScroll: false,
217219
closeMenuOnSelect,
218220
// We don't want to close if we're actually scrolling the menu

packages/grafana-ui/src/components/Select/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface SelectCommonProps<T> {
2323
/** Focus is set to the Select when rendered*/
2424
autoFocus?: boolean;
2525
backspaceRemovesValue?: boolean;
26+
blurInputOnSelect?: boolean;
2627
className?: string;
2728
closeMenuOnSelect?: boolean;
2829
/** Used for custom components. For more information, see `react-select` */

pkg/tsdb/azuremonitor/azuremonitor.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func ProvideService(cfg *setting.Cfg, httpClientProvider *httpclient.Provider, t
3535
azureMonitor: &metrics.AzureMonitorDatasource{Proxy: proxy},
3636
azureLogAnalytics: &loganalytics.AzureLogAnalyticsDatasource{Proxy: proxy},
3737
azureResourceGraph: &resourcegraph.AzureResourceGraphDatasource{Proxy: proxy},
38+
azureTraces: &loganalytics.AzureLogAnalyticsDatasource{Proxy: proxy},
3839
}
3940

4041
im := datasource.NewInstanceManager(NewInstanceSettings(cfg, httpClientProvider, executors))
@@ -86,7 +87,7 @@ func NewInstanceSettings(cfg *setting.Cfg, clientProvider *httpclient.Provider,
8687
if err != nil {
8788
return nil, fmt.Errorf("error reading settings: %w", err)
8889
}
89-
jsonDataObj := map[string]interface{}{}
90+
jsonDataObj := map[string]any{}
9091
err = json.Unmarshal(settings.JSONData, &jsonDataObj)
9192
if err != nil {
9293
return nil, fmt.Errorf("error reading settings: %w", err)
@@ -176,6 +177,9 @@ func (s *Service) getDataSourceFromPluginReq(req *backend.QueryDataRequest) (typ
176177
return types.DatasourceInfo{}, fmt.Errorf("unable to convert datasource from service instance")
177178
}
178179
dsInfo.OrgID = req.PluginContext.OrgID
180+
181+
dsInfo.DatasourceName = req.PluginContext.DataSourceInstanceSettings.Name
182+
dsInfo.DatasourceUID = req.PluginContext.DataSourceInstanceSettings.UID
179183
return dsInfo, nil
180184
}
181185

pkg/tsdb/azuremonitor/azuremonitor_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ func Test_newMux(t *testing.T) {
165165
expectedURL: routes[azureMonitorPublic][azureLogAnalytics].URL,
166166
Err: require.NoError,
167167
},
168+
{
169+
name: "creates an Azure Traces executor",
170+
queryType: azureTraces,
171+
expectedURL: routes[azureMonitorPublic][azureLogAnalytics].URL,
172+
Err: require.NoError,
173+
},
168174
}
169175

170176
for _, tt := range tests {
@@ -189,7 +195,12 @@ func Test_newMux(t *testing.T) {
189195
}
190196
mux := s.newQueryMux()
191197
res, err := mux.QueryData(context.Background(), &backend.QueryDataRequest{
192-
PluginContext: backend.PluginContext{},
198+
PluginContext: backend.PluginContext{
199+
DataSourceInstanceSettings: &backend.DataSourceInstanceSettings{
200+
Name: "datasource_name",
201+
UID: "datasource_UID",
202+
},
203+
},
193204
Queries: []backend.DataQuery{
194205
{QueryType: tt.queryType},
195206
},

pkg/tsdb/azuremonitor/kinds/dataquery/types_dataquery_gen.go

+96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)