-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Diego Sampaio <[email protected]> Co-authored-by: Ricardo Garim <[email protected]> Co-authored-by: Guilherme Gazzo <[email protected]>
- Loading branch information
1 parent
f4365b7
commit 429d000
Showing
54 changed files
with
1,243 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,4 @@ data/ | |
registration.yaml | ||
|
||
storybook-static | ||
development/tempo-data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 23 additions & 20 deletions
43
apps/meteor/app/statistics/server/functions/sendUsageReport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
import type { Logger } from '@rocket.chat/logger'; | ||
import { Statistics } from '@rocket.chat/models'; | ||
import { serverFetch as fetch } from '@rocket.chat/server-fetch'; | ||
import { tracerSpan } from '@rocket.chat/tracing'; | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { statistics } from '..'; | ||
import { getWorkspaceAccessToken } from '../../../cloud/server'; | ||
|
||
export async function sendUsageReport(logger: Logger): Promise<string | undefined> { | ||
const cronStatistics = await statistics.save(); | ||
return tracerSpan('generateStatistics', {}, async () => { | ||
const cronStatistics = await statistics.save(); | ||
|
||
try { | ||
const token = await getWorkspaceAccessToken(); | ||
const headers = { ...(token && { Authorization: `Bearer ${token}` }) }; | ||
try { | ||
const token = await getWorkspaceAccessToken(); | ||
const headers = { ...(token && { Authorization: `Bearer ${token}` }) }; | ||
|
||
const response = await fetch('https://collector.rocket.chat/', { | ||
method: 'POST', | ||
body: { | ||
...cronStatistics, | ||
host: Meteor.absoluteUrl(), | ||
}, | ||
headers, | ||
}); | ||
const response = await fetch('https://collector.rocket.chat/', { | ||
method: 'POST', | ||
body: { | ||
...cronStatistics, | ||
host: Meteor.absoluteUrl(), | ||
}, | ||
headers, | ||
}); | ||
|
||
const { statsToken } = await response.json(); | ||
const { statsToken } = await response.json(); | ||
|
||
if (statsToken != null) { | ||
await Statistics.updateOne({ _id: cronStatistics._id }, { $set: { statsToken } }); | ||
return statsToken; | ||
if (statsToken != null) { | ||
await Statistics.updateOne({ _id: cronStatistics._id }, { $set: { statsToken } }); | ||
return statsToken; | ||
} | ||
} catch (error) { | ||
/* error*/ | ||
logger.warn('Failed to send usage report'); | ||
} | ||
} catch (error) { | ||
/* error*/ | ||
logger.warn('Failed to send usage report'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import { initDatabaseTracing } from '@rocket.chat/tracing'; | ||
import { MongoInternals } from 'meteor/mongo'; | ||
|
||
export const { db, client } = MongoInternals.defaultRemoteCollectionDriver().mongo; | ||
|
||
initDatabaseTracing(client); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { startTracing } from '@rocket.chat/tracing'; | ||
|
||
startTracing({ service: 'core' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
server: | ||
log_level: debug | ||
|
||
traces: | ||
configs: | ||
- name: default | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
remote_write: | ||
- endpoint: tempo:4317 | ||
insecure: true | ||
batch: | ||
timeout: 5s | ||
send_batch_size: 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
processors: | ||
batch: | ||
timeout: 100ms | ||
|
||
exporters: | ||
logging: | ||
loglevel: debug | ||
otlp/1: | ||
endpoint: tempo:4317 | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [otlp/1] |
Oops, something went wrong.