mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 15:29:01 +08:00
chore: update telemetry events (#6804)
This commit is contained in:
parent
d5b847c091
commit
a60371fb80
@ -512,32 +512,29 @@ func extractQueryRangeData(path string, r *http.Request) (map[string]interface{}
|
|||||||
zap.L().Error("error while matching the trace explorer: ", zap.Error(err))
|
zap.L().Error("error while matching the trace explorer: ", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
signozMetricsUsed := false
|
queryInfoResult := telemetry.GetInstance().CheckQueryInfo(postData)
|
||||||
signozLogsUsed := false
|
|
||||||
signozTracesUsed := false
|
|
||||||
if postData != nil {
|
|
||||||
|
|
||||||
if postData.CompositeQuery != nil {
|
if (queryInfoResult.MetricsUsed || queryInfoResult.LogsUsed || queryInfoResult.TracesUsed) && (queryInfoResult.FilterApplied) {
|
||||||
data["queryType"] = postData.CompositeQuery.QueryType
|
if queryInfoResult.MetricsUsed {
|
||||||
data["panelType"] = postData.CompositeQuery.PanelType
|
|
||||||
|
|
||||||
signozLogsUsed, signozMetricsUsed, signozTracesUsed = telemetry.GetInstance().CheckSigNozSignals(postData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if signozMetricsUsed || signozLogsUsed || signozTracesUsed {
|
|
||||||
if signozMetricsUsed {
|
|
||||||
telemetry.GetInstance().AddActiveMetricsUser()
|
telemetry.GetInstance().AddActiveMetricsUser()
|
||||||
}
|
}
|
||||||
if signozLogsUsed {
|
if queryInfoResult.LogsUsed {
|
||||||
telemetry.GetInstance().AddActiveLogsUser()
|
telemetry.GetInstance().AddActiveLogsUser()
|
||||||
}
|
}
|
||||||
if signozTracesUsed {
|
if queryInfoResult.TracesUsed {
|
||||||
telemetry.GetInstance().AddActiveTracesUser()
|
telemetry.GetInstance().AddActiveTracesUser()
|
||||||
}
|
}
|
||||||
data["metricsUsed"] = signozMetricsUsed
|
data["metricsUsed"] = queryInfoResult.MetricsUsed
|
||||||
data["logsUsed"] = signozLogsUsed
|
data["logsUsed"] = queryInfoResult.LogsUsed
|
||||||
data["tracesUsed"] = signozTracesUsed
|
data["tracesUsed"] = queryInfoResult.TracesUsed
|
||||||
|
data["filterApplied"] = queryInfoResult.FilterApplied
|
||||||
|
data["groupByApplied"] = queryInfoResult.GroupByApplied
|
||||||
|
data["aggregateOperator"] = queryInfoResult.AggregateOperator
|
||||||
|
data["aggregateAttributeKey"] = queryInfoResult.AggregateAttributeKey
|
||||||
|
data["numberOfQueries"] = queryInfoResult.NumberOfQueries
|
||||||
|
data["queryType"] = queryInfoResult.QueryType
|
||||||
|
data["panelType"] = queryInfoResult.PanelType
|
||||||
|
|
||||||
userEmail, err := baseauth.GetEmailFromJwt(r.Context())
|
userEmail, err := baseauth.GetEmailFromJwt(r.Context())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// switch case to set data["screen"] based on the referrer
|
// switch case to set data["screen"] based on the referrer
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import './LogsExplorerList.style.scss';
|
import './LogsExplorerList.style.scss';
|
||||||
|
|
||||||
import { Card } from 'antd';
|
import { Card } from 'antd';
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import LogDetail from 'components/LogDetail';
|
import LogDetail from 'components/LogDetail';
|
||||||
import { VIEW_TYPES } from 'components/LogDetail/constants';
|
import { VIEW_TYPES } from 'components/LogDetail/constants';
|
||||||
// components
|
// components
|
||||||
@ -18,7 +19,7 @@ import { FontSize } from 'container/OptionsMenu/types';
|
|||||||
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
||||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
import { memo, useCallback, useMemo, useRef } from 'react';
|
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
||||||
// interfaces
|
// interfaces
|
||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
@ -71,7 +72,13 @@ function LogsExplorerList({
|
|||||||
() => convertKeysToColumnFields(options.selectColumns),
|
() => convertKeysToColumnFields(options.selectColumns),
|
||||||
[options],
|
[options],
|
||||||
);
|
);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isLoading && !isFetching && !isError && logs.length !== 0) {
|
||||||
|
logEvent('Logs Explorer: Data present', {
|
||||||
|
panelType: 'LIST',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, isError, logs.length]);
|
||||||
const getItemContent = useCallback(
|
const getItemContent = useCallback(
|
||||||
(_: number, log: ILog): JSX.Element => {
|
(_: number, log: ILog): JSX.Element => {
|
||||||
if (options.format === 'raw') {
|
if (options.format === 'raw') {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import './TimeSeriesView.styles.scss';
|
import './TimeSeriesView.styles.scss';
|
||||||
|
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import Uplot from 'components/Uplot';
|
import Uplot from 'components/Uplot';
|
||||||
import { QueryParams } from 'constants/query';
|
import { QueryParams } from 'constants/query';
|
||||||
import EmptyLogsSearch from 'container/EmptyLogsSearch/EmptyLogsSearch';
|
import EmptyLogsSearch from 'container/EmptyLogsSearch/EmptyLogsSearch';
|
||||||
@ -120,6 +121,20 @@ function TimeSeriesView({
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (chartData[0] && chartData[0]?.length !== 0 && !isLoading && !isError) {
|
||||||
|
if (dataSource === DataSource.TRACES) {
|
||||||
|
logEvent('Traces Explorer: Data present', {
|
||||||
|
panelType: 'TIME_SERIES',
|
||||||
|
});
|
||||||
|
} else if (dataSource === DataSource.LOGS) {
|
||||||
|
logEvent('Logs Explorer: Data present', {
|
||||||
|
panelType: 'TIME_SERIES',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [isLoading, isError, chartData, dataSource]);
|
||||||
|
|
||||||
const { timezone } = useTimezone();
|
const { timezone } = useTimezone();
|
||||||
|
|
||||||
const chartOptions = getUPlotChartOptions({
|
const chartOptions = getUPlotChartOptions({
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import { ResizeTable } from 'components/ResizeTable';
|
import { ResizeTable } from 'components/ResizeTable';
|
||||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||||
@ -18,7 +19,7 @@ import { getDraggedColumns } from 'hooks/useDragColumns/utils';
|
|||||||
import useUrlQueryData from 'hooks/useUrlQueryData';
|
import useUrlQueryData from 'hooks/useUrlQueryData';
|
||||||
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
||||||
import { useTimezone } from 'providers/Timezone';
|
import { useTimezone } from 'providers/Timezone';
|
||||||
import { memo, useCallback, useMemo } from 'react';
|
import { memo, useCallback, useEffect, useMemo } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { DataSource } from 'types/common/queryBuilder';
|
import { DataSource } from 'types/common/queryBuilder';
|
||||||
@ -145,12 +146,24 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
|||||||
[columns, onDragColumns],
|
[columns, onDragColumns],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isDataPresent =
|
const isDataAbsent =
|
||||||
!isLoading &&
|
!isLoading &&
|
||||||
!isFetching &&
|
!isFetching &&
|
||||||
!isError &&
|
!isError &&
|
||||||
transformedQueryTableData.length === 0;
|
transformedQueryTableData.length === 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
!isLoading &&
|
||||||
|
!isFetching &&
|
||||||
|
!isError &&
|
||||||
|
transformedQueryTableData.length !== 0
|
||||||
|
) {
|
||||||
|
logEvent('Traces Explorer: Data present', {
|
||||||
|
panelType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, isError, transformedQueryTableData, panelType]);
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
{transformedQueryTableData.length !== 0 && (
|
{transformedQueryTableData.length !== 0 && (
|
||||||
@ -168,11 +181,11 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
|||||||
<TracesLoading />
|
<TracesLoading />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isDataPresent && !isFilterApplied && (
|
{isDataAbsent && !isFilterApplied && (
|
||||||
<NoLogs dataSource={DataSource.TRACES} />
|
<NoLogs dataSource={DataSource.TRACES} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isDataPresent && isFilterApplied && (
|
{isDataAbsent && isFilterApplied && (
|
||||||
<EmptyLogsSearch dataSource={DataSource.TRACES} panelType="LIST" />
|
<EmptyLogsSearch dataSource={DataSource.TRACES} panelType="LIST" />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Typography } from 'antd';
|
import { Typography } from 'antd';
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import { ResizeTable } from 'components/ResizeTable';
|
import { ResizeTable } from 'components/ResizeTable';
|
||||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||||
import { QueryParams } from 'constants/query';
|
import { QueryParams } from 'constants/query';
|
||||||
@ -10,7 +11,7 @@ import { useGetQueryRange } from 'hooks/queryBuilder/useGetQueryRange';
|
|||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
import { Pagination } from 'hooks/queryPagination';
|
import { Pagination } from 'hooks/queryPagination';
|
||||||
import useUrlQueryData from 'hooks/useUrlQueryData';
|
import useUrlQueryData from 'hooks/useUrlQueryData';
|
||||||
import { memo, useMemo } from 'react';
|
import { memo, useEffect, useMemo } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { DataSource } from 'types/common/queryBuilder';
|
import { DataSource } from 'types/common/queryBuilder';
|
||||||
@ -72,6 +73,14 @@ function TracesView({ isFilterApplied }: TracesViewProps): JSX.Element {
|
|||||||
[responseData],
|
[responseData],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isLoading && !isFetching && !isError && (tableData || []).length !== 0) {
|
||||||
|
logEvent('Traces Explorer: Data present', {
|
||||||
|
panelType: 'TRACE',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, isError, panelType, tableData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
{(tableData || []).length !== 0 && (
|
{(tableData || []).length !== 0 && (
|
||||||
|
@ -11,7 +11,7 @@ import logEvent from 'api/common/logEvent';
|
|||||||
import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';
|
import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';
|
||||||
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
|
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
import { isArray, isEqual } from 'lodash-es';
|
import { isArray, isEmpty, isEqual } from 'lodash-es';
|
||||||
import {
|
import {
|
||||||
Dispatch,
|
Dispatch,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
@ -198,7 +198,7 @@ export function Filter(props: FilterProps): JSX.Element {
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (selectedFilters) {
|
if (!isEmpty(selectedFilters)) {
|
||||||
logEvent('Traces Explorer: Sidebar filter used', {
|
logEvent('Traces Explorer: Sidebar filter used', {
|
||||||
selectedFilters,
|
selectedFilters,
|
||||||
});
|
});
|
||||||
|
@ -2640,7 +2640,7 @@ func (r *ClickHouseReader) GetLogsInfoInLastHeartBeatInterval(ctx context.Contex
|
|||||||
|
|
||||||
var totalLogLines uint64
|
var totalLogLines uint64
|
||||||
|
|
||||||
queryStr := fmt.Sprintf("select count() from %s.%s where timestamp > toUnixTimestamp(now()-toIntervalMinute(%d))*1000000000;", r.logsDB, r.logsTable, int(interval.Minutes()))
|
queryStr := fmt.Sprintf("select count() from %s.%s where timestamp > toUnixTimestamp(now()-toIntervalMinute(%d))*1000000000;", r.logsDB, r.logsTableV2, int(interval.Minutes()))
|
||||||
|
|
||||||
err := r.db.QueryRow(ctx, queryStr).Scan(&totalLogLines)
|
err := r.db.QueryRow(ctx, queryStr).Scan(&totalLogLines)
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ func GetDashboardsInfo(ctx context.Context) (*model.DashboardsInfo, error) {
|
|||||||
dashboardInfo := countPanelsInDashboard(dashboard.Data)
|
dashboardInfo := countPanelsInDashboard(dashboard.Data)
|
||||||
dashboardsInfo.LogsBasedPanels += dashboardInfo.LogsBasedPanels
|
dashboardsInfo.LogsBasedPanels += dashboardInfo.LogsBasedPanels
|
||||||
dashboardsInfo.TracesBasedPanels += dashboardInfo.TracesBasedPanels
|
dashboardsInfo.TracesBasedPanels += dashboardInfo.TracesBasedPanels
|
||||||
dashboardsInfo.MetricBasedPanels += dashboardsInfo.MetricBasedPanels
|
dashboardsInfo.MetricBasedPanels += dashboardInfo.MetricBasedPanels
|
||||||
dashboardsInfo.LogsPanelsWithAttrContainsOp += dashboardInfo.LogsPanelsWithAttrContainsOp
|
dashboardsInfo.LogsPanelsWithAttrContainsOp += dashboardInfo.LogsPanelsWithAttrContainsOp
|
||||||
dashboardsInfo.DashboardsWithLogsChQuery += dashboardInfo.DashboardsWithLogsChQuery
|
dashboardsInfo.DashboardsWithLogsChQuery += dashboardInfo.DashboardsWithLogsChQuery
|
||||||
dashboardsInfo.DashboardsWithTraceChQuery += dashboardInfo.DashboardsWithTraceChQuery
|
dashboardsInfo.DashboardsWithTraceChQuery += dashboardInfo.DashboardsWithTraceChQuery
|
||||||
|
@ -4662,8 +4662,8 @@ func sendQueryResultEvents(r *http.Request, result []*v3.Result, queryRangeParam
|
|||||||
|
|
||||||
userEmail, err := auth.GetEmailFromJwt(r.Context())
|
userEmail, err := auth.GetEmailFromJwt(r.Context())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
signozLogsUsed, signozMetricsUsed, signozTracesUsed := telemetry.GetInstance().CheckSigNozSignals(queryRangeParams)
|
queryInfoResult := telemetry.GetInstance().CheckQueryInfo(queryRangeParams)
|
||||||
if signozLogsUsed || signozMetricsUsed || signozTracesUsed {
|
if queryInfoResult.LogsUsed || queryInfoResult.MetricsUsed || queryInfoResult.TracesUsed {
|
||||||
|
|
||||||
if dashboardMatched {
|
if dashboardMatched {
|
||||||
var dashboardID, widgetID string
|
var dashboardID, widgetID string
|
||||||
@ -4689,13 +4689,18 @@ func sendQueryResultEvents(r *http.Request, result []*v3.Result, queryRangeParam
|
|||||||
widgetID = widgetIDMatch[1]
|
widgetID = widgetIDMatch[1]
|
||||||
}
|
}
|
||||||
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_SUCCESSFUL_DASHBOARD_PANEL_QUERY, map[string]interface{}{
|
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_SUCCESSFUL_DASHBOARD_PANEL_QUERY, map[string]interface{}{
|
||||||
"queryType": queryRangeParams.CompositeQuery.QueryType,
|
"queryType": queryRangeParams.CompositeQuery.QueryType,
|
||||||
"panelType": queryRangeParams.CompositeQuery.PanelType,
|
"panelType": queryRangeParams.CompositeQuery.PanelType,
|
||||||
"tracesUsed": signozTracesUsed,
|
"tracesUsed": queryInfoResult.TracesUsed,
|
||||||
"logsUsed": signozLogsUsed,
|
"logsUsed": queryInfoResult.LogsUsed,
|
||||||
"metricsUsed": signozMetricsUsed,
|
"metricsUsed": queryInfoResult.MetricsUsed,
|
||||||
"dashboardId": dashboardID,
|
"numberOfQueries": queryInfoResult.NumberOfQueries,
|
||||||
"widgetId": widgetID,
|
"groupByApplied": queryInfoResult.GroupByApplied,
|
||||||
|
"aggregateOperator": queryInfoResult.AggregateOperator,
|
||||||
|
"aggregateAttributeKey": queryInfoResult.AggregateAttributeKey,
|
||||||
|
"filterApplied": queryInfoResult.FilterApplied,
|
||||||
|
"dashboardId": dashboardID,
|
||||||
|
"widgetId": widgetID,
|
||||||
}, userEmail, true, false)
|
}, userEmail, true, false)
|
||||||
}
|
}
|
||||||
if alertMatched {
|
if alertMatched {
|
||||||
@ -4712,12 +4717,17 @@ func sendQueryResultEvents(r *http.Request, result []*v3.Result, queryRangeParam
|
|||||||
alertID = alertIDMatch[1]
|
alertID = alertIDMatch[1]
|
||||||
}
|
}
|
||||||
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_SUCCESSFUL_ALERT_QUERY, map[string]interface{}{
|
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_SUCCESSFUL_ALERT_QUERY, map[string]interface{}{
|
||||||
"queryType": queryRangeParams.CompositeQuery.QueryType,
|
"queryType": queryRangeParams.CompositeQuery.QueryType,
|
||||||
"panelType": queryRangeParams.CompositeQuery.PanelType,
|
"panelType": queryRangeParams.CompositeQuery.PanelType,
|
||||||
"tracesUsed": signozTracesUsed,
|
"tracesUsed": queryInfoResult.TracesUsed,
|
||||||
"logsUsed": signozLogsUsed,
|
"logsUsed": queryInfoResult.LogsUsed,
|
||||||
"metricsUsed": signozMetricsUsed,
|
"metricsUsed": queryInfoResult.MetricsUsed,
|
||||||
"alertId": alertID,
|
"numberOfQueries": queryInfoResult.NumberOfQueries,
|
||||||
|
"groupByApplied": queryInfoResult.GroupByApplied,
|
||||||
|
"aggregateOperator": queryInfoResult.AggregateOperator,
|
||||||
|
"aggregateAttributeKey": queryInfoResult.AggregateAttributeKey,
|
||||||
|
"filterApplied": queryInfoResult.FilterApplied,
|
||||||
|
"alertId": alertID,
|
||||||
}, userEmail, true, false)
|
}, userEmail, true, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
_ "net/http/pprof" // http profiler
|
_ "net/http/pprof" // http profiler
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -462,12 +463,13 @@ func (lrw *loggingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func extractQueryRangeV3Data(path string, r *http.Request) (map[string]interface{}, bool) {
|
func extractQueryRangeV3Data(path string, r *http.Request) (map[string]interface{}, bool) {
|
||||||
pathToExtractBodyFrom := "/api/v3/query_range"
|
pathToExtractBodyFromV3 := "/api/v3/query_range"
|
||||||
|
pathToExtractBodyFromV4 := "/api/v4/query_range"
|
||||||
|
|
||||||
data := map[string]interface{}{}
|
data := map[string]interface{}{}
|
||||||
var postData *v3.QueryRangeParamsV3
|
var postData *v3.QueryRangeParamsV3
|
||||||
|
|
||||||
if path == pathToExtractBodyFrom && (r.Method == "POST") {
|
if (r.Method == "POST") && ((path == pathToExtractBodyFromV3) || (path == pathToExtractBodyFromV4)) {
|
||||||
if r.Body != nil {
|
if r.Body != nil {
|
||||||
bodyBytes, err := io.ReadAll(r.Body)
|
bodyBytes, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -485,34 +487,64 @@ func extractQueryRangeV3Data(path string, r *http.Request) (map[string]interface
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
signozMetricsUsed := false
|
referrer := r.Header.Get("Referer")
|
||||||
signozLogsUsed := false
|
|
||||||
signozTracesUsed := false
|
|
||||||
if postData != nil {
|
|
||||||
|
|
||||||
if postData.CompositeQuery != nil {
|
dashboardMatched, err := regexp.MatchString(`/dashboard/[a-zA-Z0-9\-]+/(new|edit)(?:\?.*)?$`, referrer)
|
||||||
data["queryType"] = postData.CompositeQuery.QueryType
|
if err != nil {
|
||||||
data["panelType"] = postData.CompositeQuery.PanelType
|
zap.L().Error("error while matching the referrer", zap.Error(err))
|
||||||
|
}
|
||||||
signozLogsUsed, signozMetricsUsed, signozTracesUsed = telemetry.GetInstance().CheckSigNozSignals(postData)
|
alertMatched, err := regexp.MatchString(`/alerts/(new|edit)(?:\?.*)?$`, referrer)
|
||||||
}
|
if err != nil {
|
||||||
|
zap.L().Error("error while matching the alert: ", zap.Error(err))
|
||||||
|
}
|
||||||
|
logsExplorerMatched, err := regexp.MatchString(`/logs/logs-explorer(?:\?.*)?$`, referrer)
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("error while matching the logs explorer: ", zap.Error(err))
|
||||||
|
}
|
||||||
|
traceExplorerMatched, err := regexp.MatchString(`/traces-explorer(?:\?.*)?$`, referrer)
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("error while matching the trace explorer: ", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if signozMetricsUsed || signozLogsUsed || signozTracesUsed {
|
queryInfoResult := telemetry.GetInstance().CheckQueryInfo(postData)
|
||||||
if signozMetricsUsed {
|
|
||||||
|
if (queryInfoResult.MetricsUsed || queryInfoResult.LogsUsed || queryInfoResult.TracesUsed) && (queryInfoResult.FilterApplied) {
|
||||||
|
if queryInfoResult.MetricsUsed {
|
||||||
telemetry.GetInstance().AddActiveMetricsUser()
|
telemetry.GetInstance().AddActiveMetricsUser()
|
||||||
}
|
}
|
||||||
if signozLogsUsed {
|
if queryInfoResult.LogsUsed {
|
||||||
telemetry.GetInstance().AddActiveLogsUser()
|
telemetry.GetInstance().AddActiveLogsUser()
|
||||||
}
|
}
|
||||||
if signozTracesUsed {
|
if queryInfoResult.TracesUsed {
|
||||||
telemetry.GetInstance().AddActiveTracesUser()
|
telemetry.GetInstance().AddActiveTracesUser()
|
||||||
}
|
}
|
||||||
data["metricsUsed"] = signozMetricsUsed
|
data["metricsUsed"] = queryInfoResult.MetricsUsed
|
||||||
data["logsUsed"] = signozLogsUsed
|
data["logsUsed"] = queryInfoResult.LogsUsed
|
||||||
data["tracesUsed"] = signozTracesUsed
|
data["tracesUsed"] = queryInfoResult.TracesUsed
|
||||||
|
data["filterApplied"] = queryInfoResult.FilterApplied
|
||||||
|
data["groupByApplied"] = queryInfoResult.GroupByApplied
|
||||||
|
data["aggregateOperator"] = queryInfoResult.AggregateOperator
|
||||||
|
data["aggregateAttributeKey"] = queryInfoResult.AggregateAttributeKey
|
||||||
|
data["numberOfQueries"] = queryInfoResult.NumberOfQueries
|
||||||
|
data["queryType"] = queryInfoResult.QueryType
|
||||||
|
data["panelType"] = queryInfoResult.PanelType
|
||||||
|
|
||||||
userEmail, err := auth.GetEmailFromJwt(r.Context())
|
userEmail, err := auth.GetEmailFromJwt(r.Context())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
// switch case to set data["screen"] based on the referrer
|
||||||
|
switch {
|
||||||
|
case dashboardMatched:
|
||||||
|
data["screen"] = "panel"
|
||||||
|
case alertMatched:
|
||||||
|
data["screen"] = "alert"
|
||||||
|
case logsExplorerMatched:
|
||||||
|
data["screen"] = "logs-explorer"
|
||||||
|
case traceExplorerMatched:
|
||||||
|
data["screen"] = "traces-explorer"
|
||||||
|
default:
|
||||||
|
data["screen"] = "unknown"
|
||||||
|
return data, true
|
||||||
|
}
|
||||||
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_QUERY_RANGE_API, data, userEmail, true, false)
|
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_QUERY_RANGE_API, data, userEmail, true, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,6 +618,7 @@ type TagsInfo struct {
|
|||||||
|
|
||||||
type AlertsInfo struct {
|
type AlertsInfo struct {
|
||||||
TotalAlerts int `json:"totalAlerts"`
|
TotalAlerts int `json:"totalAlerts"`
|
||||||
|
TotalActiveAlerts int `json:"totalActiveAlerts"`
|
||||||
LogsBasedAlerts int `json:"logsBasedAlerts"`
|
LogsBasedAlerts int `json:"logsBasedAlerts"`
|
||||||
MetricBasedAlerts int `json:"metricBasedAlerts"`
|
MetricBasedAlerts int `json:"metricBasedAlerts"`
|
||||||
AnomalyBasedAlerts int `json:"anomalyBasedAlerts"`
|
AnomalyBasedAlerts int `json:"anomalyBasedAlerts"`
|
||||||
|
@ -616,6 +616,9 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
alertsInfo.TotalAlerts = alertsInfo.TotalAlerts + 1
|
alertsInfo.TotalAlerts = alertsInfo.TotalAlerts + 1
|
||||||
|
if rule.PostableRule.Disabled == false {
|
||||||
|
alertsInfo.TotalActiveAlerts = alertsInfo.TotalActiveAlerts + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
alertsInfo.AlertNames = alertNames
|
alertsInfo.AlertNames = alertNames
|
||||||
|
|
||||||
|
@ -82,6 +82,19 @@ var OSS_EVENTS_LIST = map[string]struct{}{
|
|||||||
TELEMETRY_LICENSE_ACT_FAILED: {},
|
TELEMETRY_LICENSE_ACT_FAILED: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QueryInfoResult struct {
|
||||||
|
LogsUsed bool
|
||||||
|
MetricsUsed bool
|
||||||
|
TracesUsed bool
|
||||||
|
FilterApplied bool
|
||||||
|
GroupByApplied bool
|
||||||
|
AggregateOperator v3.AggregateOperator
|
||||||
|
AggregateAttributeKey string
|
||||||
|
QueryType v3.QueryType
|
||||||
|
PanelType v3.PanelType
|
||||||
|
NumberOfQueries int
|
||||||
|
}
|
||||||
|
|
||||||
const api_key = "9kRrJ7oPCGPEJLF6QjMPLt5bljFhRQBr"
|
const api_key = "9kRrJ7oPCGPEJLF6QjMPLt5bljFhRQBr"
|
||||||
|
|
||||||
const IP_NOT_FOUND_PLACEHOLDER = "NA"
|
const IP_NOT_FOUND_PLACEHOLDER = "NA"
|
||||||
@ -107,43 +120,54 @@ func (a *Telemetry) IsSampled() bool {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (telemetry *Telemetry) CheckSigNozSignals(postData *v3.QueryRangeParamsV3) (bool, bool, bool) {
|
func (telemetry *Telemetry) CheckQueryInfo(postData *v3.QueryRangeParamsV3) QueryInfoResult {
|
||||||
signozLogsUsed := false
|
queryInfoResult := QueryInfoResult{}
|
||||||
signozMetricsUsed := false
|
if postData != nil && postData.CompositeQuery != nil {
|
||||||
signozTracesUsed := false
|
queryInfoResult.PanelType = postData.CompositeQuery.PanelType
|
||||||
|
queryInfoResult.QueryType = postData.CompositeQuery.QueryType
|
||||||
|
if postData.CompositeQuery.QueryType == v3.QueryTypeBuilder {
|
||||||
|
queryInfoResult.NumberOfQueries = len(postData.CompositeQuery.BuilderQueries)
|
||||||
|
for _, query := range postData.CompositeQuery.BuilderQueries {
|
||||||
|
if query.DataSource == v3.DataSourceLogs {
|
||||||
|
queryInfoResult.LogsUsed = true
|
||||||
|
} else if query.DataSource == v3.DataSourceMetrics {
|
||||||
|
queryInfoResult.MetricsUsed = true
|
||||||
|
|
||||||
if postData.CompositeQuery.QueryType == v3.QueryTypeBuilder {
|
} else if query.DataSource == v3.DataSourceTraces {
|
||||||
for _, query := range postData.CompositeQuery.BuilderQueries {
|
queryInfoResult.TracesUsed = true
|
||||||
if query.DataSource == v3.DataSourceLogs && query.Filters != nil && len(query.Filters.Items) > 0 {
|
}
|
||||||
signozLogsUsed = true
|
if query.Filters != nil && len(query.Filters.Items) > 0 {
|
||||||
} else if query.DataSource == v3.DataSourceMetrics &&
|
queryInfoResult.FilterApplied = true
|
||||||
!strings.Contains(query.AggregateAttribute.Key, "signoz_") &&
|
}
|
||||||
len(query.AggregateAttribute.Key) > 0 {
|
if query.GroupBy != nil && len(query.GroupBy) > 0 {
|
||||||
signozMetricsUsed = true
|
queryInfoResult.GroupByApplied = true
|
||||||
} else if query.DataSource == v3.DataSourceTraces && query.Filters != nil && len(query.Filters.Items) > 0 {
|
}
|
||||||
signozTracesUsed = true
|
queryInfoResult.AggregateOperator = query.AggregateOperator
|
||||||
|
if len(query.AggregateAttribute.Key) > 0 && !strings.Contains(query.AggregateAttribute.Key, "signoz_") {
|
||||||
|
queryInfoResult.AggregateAttributeKey = query.AggregateAttribute.Key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if postData.CompositeQuery.QueryType == v3.QueryTypePromQL {
|
||||||
} else if postData.CompositeQuery.QueryType == v3.QueryTypePromQL {
|
for _, query := range postData.CompositeQuery.PromQueries {
|
||||||
for _, query := range postData.CompositeQuery.PromQueries {
|
if !strings.Contains(query.Query, "signoz_") && len(query.Query) > 0 {
|
||||||
if !strings.Contains(query.Query, "signoz_") && len(query.Query) > 0 {
|
queryInfoResult.MetricsUsed = true
|
||||||
signozMetricsUsed = true
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if postData.CompositeQuery.QueryType == v3.QueryTypeClickHouseSQL {
|
||||||
} else if postData.CompositeQuery.QueryType == v3.QueryTypeClickHouseSQL {
|
for _, query := range postData.CompositeQuery.ClickHouseQueries {
|
||||||
for _, query := range postData.CompositeQuery.ClickHouseQueries {
|
if strings.Contains(query.Query, "signoz_metrics") && len(query.Query) > 0 {
|
||||||
if strings.Contains(query.Query, "signoz_metrics") && len(query.Query) > 0 {
|
queryInfoResult.MetricsUsed = true
|
||||||
signozMetricsUsed = true
|
}
|
||||||
}
|
if strings.Contains(query.Query, "signoz_logs") && len(query.Query) > 0 {
|
||||||
if strings.Contains(query.Query, "signoz_logs") && len(query.Query) > 0 {
|
queryInfoResult.LogsUsed = true
|
||||||
signozLogsUsed = true
|
}
|
||||||
}
|
if strings.Contains(query.Query, "signoz_traces") && len(query.Query) > 0 {
|
||||||
if strings.Contains(query.Query, "signoz_traces") && len(query.Query) > 0 {
|
queryInfoResult.TracesUsed = true
|
||||||
signozTracesUsed = true
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return signozLogsUsed, signozMetricsUsed, signozTracesUsed
|
return queryInfoResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (telemetry *Telemetry) AddActiveTracesUser() {
|
func (telemetry *Telemetry) AddActiveTracesUser() {
|
||||||
@ -350,6 +374,7 @@ func createTelemetry() {
|
|||||||
"dashboardWithTraceChQuery": dashboardsInfo.DashboardsWithTraceChQuery,
|
"dashboardWithTraceChQuery": dashboardsInfo.DashboardsWithTraceChQuery,
|
||||||
"dashboardNamesWithTraceChQuery": dashboardsInfo.DashboardNamesWithTraceChQuery,
|
"dashboardNamesWithTraceChQuery": dashboardsInfo.DashboardNamesWithTraceChQuery,
|
||||||
"totalAlerts": alertsInfo.TotalAlerts,
|
"totalAlerts": alertsInfo.TotalAlerts,
|
||||||
|
"totalActiveAlerts": alertsInfo.TotalActiveAlerts,
|
||||||
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
|
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
|
||||||
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
||||||
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
|
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
|
||||||
@ -383,6 +408,23 @@ func createTelemetry() {
|
|||||||
telemetry.SendEvent(TELEMETRY_EVENT_DASHBOARDS_ALERTS, dashboardsAlertsData, user.Email, false, false)
|
telemetry.SendEvent(TELEMETRY_EVENT_DASHBOARDS_ALERTS, dashboardsAlertsData, user.Email, false, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
telemetry.SendIdentityEvent(map[string]interface{}{
|
||||||
|
"total_logs": totalLogs,
|
||||||
|
"total_traces": totalSpans,
|
||||||
|
"total_metrics": totalSamples,
|
||||||
|
"total_users": userCount,
|
||||||
|
"total_channels": alertsInfo.TotalChannels,
|
||||||
|
"total_dashboards_with_panel": dashboardsInfo.TotalDashboardsWithPanelAndName,
|
||||||
|
"total_saved_views": savedViewsInfo.TotalSavedViews,
|
||||||
|
"total_active_alerts": alertsInfo.TotalActiveAlerts,
|
||||||
|
"total_traces_based_alerts": alertsInfo.TracesBasedAlerts,
|
||||||
|
"total_logs_based_alerts": alertsInfo.LogsBasedAlerts,
|
||||||
|
"total_metric_based_alerts": alertsInfo.MetricBasedAlerts,
|
||||||
|
"total_anomaly_based_alerts": alertsInfo.AnomalyBasedAlerts,
|
||||||
|
"total_metrics_based_panels": dashboardsInfo.MetricBasedPanels,
|
||||||
|
"total_logs_based_panels": dashboardsInfo.LogsBasedPanels,
|
||||||
|
"total_traces_based_panels": dashboardsInfo.TracesBasedPanels,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,6 +432,16 @@ func createTelemetry() {
|
|||||||
telemetry.SendEvent(TELEMETRY_EVENT_DASHBOARDS_ALERTS, map[string]interface{}{"error": err.Error()}, "", true, false)
|
telemetry.SendEvent(TELEMETRY_EVENT_DASHBOARDS_ALERTS, map[string]interface{}{"error": err.Error()}, "", true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if totalLogs > 0 {
|
||||||
|
telemetry.SendIdentityEvent(map[string]interface{}{"sent_logs": true})
|
||||||
|
}
|
||||||
|
if totalSpans > 0 {
|
||||||
|
telemetry.SendIdentityEvent(map[string]interface{}{"sent_traces": true})
|
||||||
|
}
|
||||||
|
if totalSamples > 0 {
|
||||||
|
telemetry.SendIdentityEvent(map[string]interface{}{"sent_metrics": true})
|
||||||
|
}
|
||||||
|
|
||||||
getDistributedInfoInLastHeartBeatInterval, _ := telemetry.reader.GetDistributedInfoInLastHeartBeatInterval(ctx)
|
getDistributedInfoInLastHeartBeatInterval, _ := telemetry.reader.GetDistributedInfoInLastHeartBeatInterval(ctx)
|
||||||
telemetry.SendEvent(TELEMETRY_EVENT_DISTRIBUTED, getDistributedInfoInLastHeartBeatInterval, "", true, false)
|
telemetry.SendEvent(TELEMETRY_EVENT_DISTRIBUTED, getDistributedInfoInLastHeartBeatInterval, "", true, false)
|
||||||
}
|
}
|
||||||
@ -518,6 +570,42 @@ func (a *Telemetry) IdentifyUser(user *model.User) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Telemetry) SendIdentityEvent(data map[string]interface{}) {
|
||||||
|
|
||||||
|
if !a.isTelemetryEnabled() || a.isTelemetryAnonymous() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
traits := analytics.NewTraits()
|
||||||
|
|
||||||
|
for k, v := range data {
|
||||||
|
traits.Set(k, v)
|
||||||
|
}
|
||||||
|
if a.saasOperator != nil {
|
||||||
|
|
||||||
|
a.saasOperator.Enqueue(analytics.Identify{
|
||||||
|
UserId: a.GetUserEmail(),
|
||||||
|
Traits: traits,
|
||||||
|
})
|
||||||
|
a.saasOperator.Enqueue(analytics.Group{
|
||||||
|
UserId: a.userEmail,
|
||||||
|
GroupId: a.getCompanyDomain(),
|
||||||
|
Traits: traits,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if a.ossOperator != nil {
|
||||||
|
a.ossOperator.Enqueue(analytics.Identify{
|
||||||
|
UserId: a.ipAddress,
|
||||||
|
Traits: traits,
|
||||||
|
})
|
||||||
|
// Updating a groups properties
|
||||||
|
a.ossOperator.Enqueue(analytics.Group{
|
||||||
|
UserId: a.ipAddress,
|
||||||
|
GroupId: a.getCompanyDomain(),
|
||||||
|
Traits: traits,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Telemetry) SetUserEmail(email string) {
|
func (a *Telemetry) SetUserEmail(email string) {
|
||||||
a.userEmail = email
|
a.userEmail = email
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user