Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions webapp_demo/hello_django/hello_django/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""
Django settings for hello_django project.

Expand Down
18 changes: 17 additions & 1 deletion webapp_demo/hello_django/hello_django/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""hello_django URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
Expand All @@ -13,7 +28,8 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.conf.urls import include
from django.conf.urls import url
from django.contrib import admin

urlpatterns = [
Expand Down
15 changes: 15 additions & 0 deletions webapp_demo/hello_django/hello_django/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""
WSGI config for hello_django project.

Expand Down
16 changes: 15 additions & 1 deletion webapp_demo/hello_django/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import os
import sys

Expand All @@ -11,7 +25,7 @@
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
import django # noqa:F401
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
Expand Down
17 changes: 16 additions & 1 deletion webapp_demo/hello_django/prometheus_app/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
from django.contrib import admin
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django.contrib import admin # noqa: F401

# Register your models here.
15 changes: 15 additions & 0 deletions webapp_demo/hello_django/prometheus_app/apps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from __future__ import unicode_literals

from django.apps import AppConfig
Expand Down
17 changes: 16 additions & 1 deletion webapp_demo/hello_django/prometheus_app/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from __future__ import unicode_literals

from django.db import models
from django.db import models # noqa: F401

# Create your models here.
17 changes: 16 additions & 1 deletion webapp_demo/hello_django/prometheus_app/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
from django.test import TestCase
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django.test import TestCase # noqa: F401

# Create your tests here.
17 changes: 16 additions & 1 deletion webapp_demo/hello_django/prometheus_app/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# howdy/urls.py
from django.conf.urls import url
from prometheus_app import views

urlpatterns = [
url(r'^$', views.HomePageView.as_view()),
]
]
22 changes: 19 additions & 3 deletions webapp_demo/hello_django/prometheus_app/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
#!/usr/bin/env python
# coding=utf-8

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# prometheus_app/views.py
from django.shortcuts import render
from django.views.generic import TemplateView

from prometheus_client import start_http_server, Counter
from prometheus_client import Counter
from prometheus_client import start_http_server

CLICK_TIME = Counter('button_click_counter', 'Counter for a button',
['version', 'button_name'])
Expand All @@ -16,8 +32,8 @@
class HomePageView(TemplateView):
def get(self, request, **kwargs):
context = {
'current_value': 0.0
}
'current_value': 0.0
}
if request.GET.get('click_btn'):
CLICK_TIME.labels(version='v1.0', button_name='START').inc(
amount=1)
Expand Down